Jama.Matrix类的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(10.7k)|赞(0)|评价(0)|浏览(380)

本文整理了Java中Jama.Matrix类的一些代码示例,展示了Matrix类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Matrix类的具体详情如下:
包路径:Jama.Matrix
类名称:Matrix

Matrix介绍

暂无

代码示例

代码示例来源:origin: stackoverflow.com

private Bitmap overlay(Bitmap bmp1, Bitmap bmp2) {
   Bitmap bmOverlay = Bitmap.createBitmap(bmp1.getWidth(), bmp1.getHeight(), bmp1.getConfig());
   Canvas canvas = new Canvas(bmOverlay);
   canvas.drawBitmap(bmp1, new Matrix(), null);
   canvas.drawBitmap(bmp2, new Matrix(), null);
   return bmOverlay;
 }

代码示例来源:origin: h2oai/h2o-3

final Matrix inv_hessian = new Matrix(cs._hessian).inverse();
for (int j = 0; j < n_coef; ++j) {
 for (int k = 0; k <= j; ++k) {
  final double elem = -inv_hessian.get(j, k);
  o._var_coef[j][k] = elem;
  o._var_coef[k][j] = elem;

代码示例来源:origin: marytts/marytts

public void predictValues(String fileName, int indVariable, int[] c, boolean interceptTerm, int rowIni, int rowEnd) {
  try {
    BufferedReader reader = new BufferedReader(new FileReader(fileName));
    Matrix data = Matrix.read(reader);
    reader.close();
    int rows = data.getRowDimension() - 1;
    int cols = data.getColumnDimension() - 1;
    Matrix indVar = data.getMatrix(rowIni, rowEnd, indVariable, indVariable); // dataVowels(:,0) -> last col is the
    data = data.getMatrix(rowIni, rowEnd, c); // the dependent variables correspond to the column indices in c
      if (b.getRowDimension() == numCoeff) {
          int row = data.getRowDimension();
          int col = data.getColumnDimension();
          Matrix B = new Matrix(row, col + 1);
          Matrix ones = new Matrix(row, 1);
          for (int i = 0; i < row; i++)
            ones.set(i, 0, 1.0);
          B.setMatrix(0, row - 1, 0, 0, ones);
          B.setMatrix(0, row - 1, 1, col, data);
          data = B;
        Matrix r = data.times(b).minus(indVar);
        residuals = r.getColumnPackedCopy();
        Matrix p = data.times(b);
        predictedValues = p.getColumnPackedCopy();

代码示例来源:origin: stackoverflow.com

Matrix matrix = new Matrix();
imageView.setScaleType(ImageView.ScaleType.MATRIX);   //required
matrix.postRotate((float) angle, pivotX, pivotY);
imageView.setImageMatrix(matrix);

代码示例来源:origin: stackoverflow.com

public static Bitmap rotateImage(Bitmap source, float angle) {
  Matrix matrix = new Matrix();
  matrix.postRotate(angle);
  return Bitmap.createBitmap(source, 0, 0, source.getWidth(), source.getHeight(),
                matrix, true);
}

代码示例来源:origin: marytts/marytts

public double[][] getDataProjected(Matrix data, boolean debug) {
  // Project the original data set
  Matrix dataProjected;
  dataProjected = PC.transpose().times(data);
  if (debug) {
    System.out.println("Data projected:");
    dataProjected.print(dataProjected.getRowDimension(), 3);
  }
  return dataProjected.getArray();
}

代码示例来源:origin: stackoverflow.com

int framesCountAvg=0;
long framesTimer=0;
Paint fpsPaint=new Paint();
  dBgrY = 1; //Scrolling background speed
  fpsPaint.setTextSize(30);
  bgrW = bgr.getWidth();
  bgrH = bgr.getHeight();
  Matrix matrix = new Matrix();  //Like a frame or mould for an image.
  matrix.setScale(-1, 1); //Horizontal mirror effect.
  bgrReverse = Bitmap.createBitmap(bgr, 0, 0, bgrW, bgrH, matrix, true); //Create a new mirrored bitmap by applying the matrix.
    canvas.drawBitmap(bgr, fromRect1, toRect1, null);
    canvas.drawBitmap(bgrReverse, fromRect2, toRect2, null);
    canvas.drawBitmap(bgr, fromRect2, toRect2, null);
    canvas.drawBitmap(bgrReverse, fromRect1, toRect1, null);

代码示例来源:origin: stackoverflow.com

final Bitmap mask = Bitmap.createBitmap(dstWidth, dstHeight, Config.ALPHA_8);
final Matrix scaleToFit = new Matrix();
final RectF src = new RectF(0, 0, bm.getWidth(), bm.getHeight());
final RectF dst = new RectF(0, 0, dstWidth - dx, dstHeight - dy);
scaleToFit.setRectToRect(src, dst, ScaleToFit.CENTER);
dropShadow.postTranslate(dx, dy);
maskCanvas.drawBitmap(bm, scaleToFit, paint);
paint.setXfermode(new PorterDuffXfermode(Mode.SRC_OUT));
maskCanvas.drawBitmap(bm, dropShadow, paint);
paint.reset();
paint.setAntiAlias(true);
paint.setColor(color);
paint.setMaskFilter(filter);
retCanvas.drawBitmap(mask, 0,  0, paint);
retCanvas.drawBitmap(bm, scaleToFit, null);
mask.recycle();
return ret;

代码示例来源:origin: stackoverflow.com

public Bitmap applyReflection(Drawable drawable) {
  Bitmap originalImage = ((BitmapDrawable)drawable).getBitmap();
  final int reflectionGap = 4;
  int width = originalImage.getWidth();
  int height = originalImage.getHeight();           
  Matrix matrix = new Matrix();
  matrix.preScale(1, -1);
  Bitmap reflectionImage = Bitmap.createBitmap(originalImage, 0, height/2, width, height/2, matrix, false);          
  Bitmap bitmapWithReflection = Bitmap.createBitmap(width, (height + height/2), Config.ARGB_8888);
  Canvas canvas = new Canvas(bitmapWithReflection);
  canvas.drawBitmap(originalImage, 0, 0, null);
  Paint defaultPaint = new Paint();
  canvas.drawRect(0, height, width, height + reflectionGap, defaultPaint);
  canvas.drawBitmap(reflectionImage,0, height + reflectionGap, null);

  Paint paint = new Paint();
  LinearGradient shader = new LinearGradient(0, originalImage.getHeight(), 0,

      bitmapWithReflection.getHeight() + reflectionGap, 0x70ffffff, 0x00ffffff, TileMode.CLAMP);
  paint.setShader(shader);
  paint.setXfermode(new PorterDuffXfermode(Mode.DST_IN));
  canvas.drawRect(0, height, width, bitmapWithReflection.getHeight() + reflectionGap, paint);

  return bitmapWithReflection;
}

代码示例来源:origin: stackoverflow.com

canvas.save();
canvas.drawBitmap(RotateBitmap(mImage, 90f), 0, 0, null);
canvas.restore();
Matrix matrix = new Matrix();
matrix.postRotate(angle);
return Bitmap.createBitmap(source, 0, 0, source.getWidth(), source.getHeight(), matrix, true);

代码示例来源:origin: stackoverflow.com

public static Bitmap CreateScaledBitmap(Bitmap src, int dstWidth, int dstHeight, boolean filter)
{
  Matrix m = new Matrix();
  m.setScale(dstWidth  / (float)src.getWidth(), dstHeight / (float)src.getHeight());
  Bitmap result = Bitmap.createBitmap(dstWidth, dstHeight, src.getConfig());
  Canvas canvas = new Canvas(result);

    Paint paint = new Paint();
    paint.setFilterBitmap(filter);
    canvas.drawBitmap(src, m, paint);

  return result;

}

代码示例来源:origin: stackoverflow.com

String filePath = getRealPathFromURI(imageUri);
Bitmap scaledBitmap = null;
options.inSampleSize = calculateInSampleSize(options, actualWidth, actualHeight);
float middleY = actualHeight / 2.0f;
Matrix scaleMatrix = new Matrix();
scaleMatrix.setScale(ratioX, ratioY, middleX, middleY);
canvas.setMatrix(scaleMatrix);
canvas.drawBitmap(bmp, middleX - bmp.getWidth() / 2, middleY - bmp.getHeight() / 2, new Paint(Paint.FILTER_BITMAP_FLAG));
  exif = new ExifInterface(filePath);
  int orientation = exif.getAttributeInt(
      ExifInterface.TAG_ORIENTATION, 0);
  Log.d("EXIF", "Exif: " + orientation);
  Matrix matrix = new Matrix();
  if (orientation == 6) {
    matrix.postRotate(90);
    Log.d("EXIF", "Exif: " + orientation);
  } else if (orientation == 3) {
    matrix.postRotate(180);
    Log.d("EXIF", "Exif: " + orientation);
  } else if (orientation == 8) {
    matrix.postRotate(270);
    Log.d("EXIF", "Exif: " + orientation);

代码示例来源:origin: stackoverflow.com

private final Matrix mMatrix = new Matrix();
    mPaint = new Paint();
    mPaint.setAntiAlias(true);
    mPaint.setFilterBitmap(true);
  mPaint.setColorFilter(calculateLight((float) degree));
  mMatrix.preTranslate(-centerX, -centerY);
  mMatrix.postTranslate(centerX, centerY);
  mMatrix.postTranslate(left, top);
  canvas.drawBitmap(bitmap, mMatrix, mPaint);
  return false;

代码示例来源:origin: stackoverflow.com

public Bitmap BITMAP_RESIZER(Bitmap bitmap,int newWidth,int newHeight) {    
 Bitmap scaledBitmap = Bitmap.createBitmap(newWidth, newHeight, Config.ARGB_8888);
 float ratioX = newWidth / (float) bitmap.getWidth();
 float ratioY = newHeight / (float) bitmap.getHeight();
 float middleX = newWidth / 2.0f;
 float middleY = newHeight / 2.0f;
 Matrix scaleMatrix = new Matrix();
 scaleMatrix.setScale(ratioX, ratioY, middleX, middleY);
 Canvas canvas = new Canvas(scaledBitmap);
 canvas.setMatrix(scaleMatrix);
 canvas.drawBitmap(bitmap, middleX - bitmap.getWidth() / 2, middleY - bitmap.getHeight() / 2, new Paint(Paint.FILTER_BITMAP_FLAG));
 return scaledBitmap;
 }

代码示例来源:origin: stackoverflow.com

BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
BitmapFactory.decodeFile(STRING_PATH_TO_FILE, options);
Matrix matrix = new Matrix();
matrix.postScale(desiredScale, desiredScale);
Bitmap scaledBitmap = Bitmap.createBitmap(sampledSrcBitmap, 0, 0, sampledSrcBitmap.getWidth(), sampledSrcBitmap.getHeight(), matrix, true);
sampledSrcBitmap = null;
scaledBitmap.compress(Bitmap.CompressFormat.JPEG, 100, out);
scaledBitmap = null;

代码示例来源:origin: stackoverflow.com

public Bitmap getResizedBitmap(Bitmap bm, int newWidth, int newHeight) {
  int width = bm.getWidth();
  int height = bm.getHeight();
  float scaleWidth = ((float) newWidth) / width;
  float scaleHeight = ((float) newHeight) / height;
  // CREATE A MATRIX FOR THE MANIPULATION
  Matrix matrix = new Matrix();
  // RESIZE THE BIT MAP
  matrix.postScale(scaleWidth, scaleHeight);

  // "RECREATE" THE NEW BITMAP
  Bitmap resizedBitmap = Bitmap.createBitmap(
    bm, 0, 0, width, height, matrix, false);
  bm.recycle();
  return resizedBitmap;
}

代码示例来源:origin: stackoverflow.com

Bitmap scaledBitmap = null;
BitmapFactory.Options options = new BitmapFactory.Options();
float middleY = actualHeight / 2.0f;
Matrix scaleMatrix = new Matrix();
scaleMatrix.setScale(ratioX, ratioY, middleX, middleY);
canvas.setMatrix(scaleMatrix);
canvas.drawBitmap(bmp, middleX - bmp.getWidth() / 2, middleY - bmp.getHeight() / 2, new Paint(Paint.FILTER_BITMAP_FLAG));
  exif = new ExifInterface(filePath);
  int orientation = exif.getAttributeInt(
      ExifInterface.TAG_ORIENTATION, 0);
  Log.d("EXIF", "Exif: " + orientation);
  Matrix matrix = new Matrix();
  if (orientation == 6) {
    matrix.postRotate(90);
    Log.d("EXIF", "Exif: " + orientation);
  } else if (orientation == 3) {
    matrix.postRotate(180);
    Log.d("EXIF", "Exif: " + orientation);
  } else if (orientation == 8) {
    matrix.postRotate(270);
    Log.d("EXIF", "Exif: " + orientation);

代码示例来源:origin: stackoverflow.com

Bitmap background = Bitmap.createBitmap((int)width, (int)height, Config.ARGB_8888);

float originalWidth = originalImage.getWidth(); 
float originalHeight = originalImage.getHeight();

Canvas canvas = new Canvas(background);

float scale = width / originalWidth;

float xTranslation = 0.0f;
float yTranslation = (height - originalHeight * scale) / 2.0f;

Matrix transformation = new Matrix();
transformation.postTranslate(xTranslation, yTranslation);
transformation.preScale(scale, scale);

Paint paint = new Paint();
paint.setFilterBitmap(true);

canvas.drawBitmap(originalImage, transformation, paint);

return background;

代码示例来源:origin: stackoverflow.com

Bitmap targetBitmap = Bitmap.createBitmap(targetWidth, targetHeight, config);
Canvas canvas = new Canvas(targetBitmap);
Matrix matrix = new Matrix();
matrix.setRotate(mRotation,source.getWidth()/2,source.getHeight()/2);
canvas.drawBitmap(source, matrix, new Paint());

代码示例来源:origin: stackoverflow.com

ExifInterface exif=new ExifInterface(pictureFile.toString());
  Log.d("EXIF value", exif.getAttribute(ExifInterface.TAG_ORIENTATION));
  if(exif.getAttribute(ExifInterface.TAG_ORIENTATION).equalsIgnoreCase("6")){
    realImage= rotate(realImage, 90);
  } else if(exif.getAttribute(ExifInterface.TAG_ORIENTATION).equalsIgnoreCase("8")){
    realImage= rotate(realImage, 270);
  } else if(exif.getAttribute(ExifInterface.TAG_ORIENTATION).equalsIgnoreCase("3")){
    realImage= rotate(realImage, 180);
  } else if(exif.getAttribute(ExifInterface.TAG_ORIENTATION).equalsIgnoreCase("0")){
    realImage= rotate(realImage, 90);
  boolean bo = realImage.compress(Bitmap.CompressFormat.JPEG, 100, fos);
int w = bitmap.getWidth();
int h = bitmap.getHeight();
Matrix mtx = new Matrix();
mtx.setRotate(degree);

相关文章