private static void writeRasterInRaw(PlanarImage image, FileRawImage[] newSeries, ImageCV[] builImgs, ViewParameter params, int dstHeight, int imgIndex) throws IOException { ImageCV img = ImageProcessor.getRotatedImage(image.toMat(), params.rotateCvType); if (newSeries != null && img != null && img.height() == newSeries.length) { if (newSeries[0] == null) { File dir = new File(MPR_CACHE_DIR, params.seriesUID); dir.mkdirs(); for (int i = 0; i < newSeries.length; i++) { newSeries[i] = new FileRawImage(new File(dir, "mpr_" + (i + 1) + ".wcv"));//$NON-NLS-1$ //$NON-NLS-2$ builImgs[i] = new ImageCV(dstHeight, img.width(), img.type()); } } for (int j = 0; j < newSeries.length; j++) { img.row(j).copyTo(builImgs[j].row(imgIndex - 1)); } } }
public static ImageCV maxStack(List<ImageElement> sources) { if (sources.size() > 1) { ImageElement firstImg = sources.get(0); ImageCV dstImg = new ImageCV(); PlanarImage img = firstImg.getImage(null, false); img.toMat().copyTo(dstImg); int numbSrc = sources.size(); for (int i = 1; i < numbSrc; i++) { ImageElement imgElement = sources.get(i); PlanarImage image = imgElement.getImage(null, false); if (image.width() != dstImg.width() && image.height() != dstImg.height()) { continue; } if (image instanceof Mat) { Core.max(dstImg, (Mat) image, dstImg); } } return dstImg; } return null; } }
public static ImageCV minStack(List<ImageElement> sources) { if (sources.size() > 1) { ImageElement firstImg = sources.get(0); ImageCV dstImg = new ImageCV(); PlanarImage img = firstImg.getImage(null, false); img.toMat().copyTo(dstImg); int numbSrc = sources.size(); for (int i = 1; i < numbSrc; i++) { ImageElement imgElement = sources.get(i); PlanarImage image = imgElement.getImage(null, false); if (image.width() != dstImg.width() && image.height() != dstImg.height()) { continue; } if (image instanceof Mat) { Core.min(dstImg, (Mat) image, dstImg); } } return dstImg; } return null; }
public static ImageCV applyCropMask(Mat source, Rectangle b, double alpha) { Mat srcImg = Objects.requireNonNull(source); ImageCV dstImg = new ImageCV(); source.copyTo(dstImg); if(b.getY() > 0) { Imgproc.rectangle(dstImg, new Point(0.0, 0.0), new Point(dstImg.width(), b.getMinY() ), new Scalar(0), -1); } if(b.getX() > 0) { Imgproc.rectangle(dstImg, new Point(0.0, b.getMinY()), new Point(b.getMinX(), b.getMaxY() ), new Scalar(0), -1); } if(b.getX() < dstImg.width()) { Imgproc.rectangle(dstImg, new Point(b.getMaxX(), b.getMinY()), new Point(dstImg.width(), b.getMaxY() ), new Scalar(0), -1); } if(b.getY() < dstImg.height()) { Imgproc.rectangle(dstImg, new Point(0.0, b.getMaxY()), new Point(dstImg.width(), dstImg.height() ), new Scalar(0), -1); } Core.addWeighted(dstImg, alpha, srcImg, 1- alpha, 0.0, dstImg); return dstImg; }