use of java.awt.image.DataBufferByte in project vcell by virtualcell.
the class ROIMultiPaintManager method fillVoids.
private boolean fillVoids(BufferedImage[] roiPixels, boolean bCheckOnly) throws Exception {
if (true) {
throw new IllegalArgumentException("Not yet implemented fully");
}
boolean bHadAnyInternalVoids = false;
int xSize = roiPixels[0].getWidth();
int ySize = roiPixels[0].getHeight();
int zSize = roiPixels.length;
int XYSIZE = xSize * ySize;
boolean bUseZ = roiPixels.length > 1;
VCImage checkImage = ROIMultiPaintManager.createVCImageFromBufferedImages(getImageDataSetChannel().getExtent(), roiComposite);
RegionImage regionImage = new RegionImage(checkImage, 0, /*0 means generate no surfacecollection*/
checkImage.getExtent(), getImageDataSetChannel().getAllImages()[0].getOrigin(), RegionImage.NO_SMOOTHING, progressWaitPopup);
RegionInfo[] newRegionInfos = regionImage.getRegionInfos();
for (int i = 0; i < newRegionInfos.length; i++) {
if (newRegionInfos[i].getPixelValue() == 0) {
boolean bInternalVoid = true;
for (int z = 0; z < zSize; z++) {
int zOffset = z * XYSIZE;
for (int y = 0; y < ySize; y++) {
int yoffset = y * xSize;
int zyOffset = zOffset + yoffset;
for (int x = 0; x < xSize; x++) {
if (newRegionInfos[i].isIndexInRegion(zyOffset + x)) {
if (x == 0 || y == 0 | (bUseZ && z == 0) | x == (xSize - 1) || y == (ySize - 1) || (bUseZ && z == (zSize - 1))) {
bInternalVoid = false;
break;
}
}
}
if (!bInternalVoid) {
break;
}
}
if (!bInternalVoid) {
break;
}
}
if (bInternalVoid) {
bHadAnyInternalVoids = true;
if (bCheckOnly) {
return bHadAnyInternalVoids;
}
for (int z = 0; z < zSize; z++) {
byte[] roiPixelsBytes = ((DataBufferByte) roiPixels[z].getRaster().getDataBuffer()).getData();
for (int xy = 0; xy < XYSIZE; xy++) {
// if(newRegionInfos[i].isIndexInRegion(j)){
// fillvoidPixels[j]|= 0xFFFF;
// }
}
}
}
}
}
return bHadAnyInternalVoids;
}
use of java.awt.image.DataBufferByte in project vcell by virtualcell.
the class ROIMultiPaintManager method duplicateROIData.
private void duplicateROIData(final int newZSize) {
final AsynchClientTask extrudeTask = new AsynchClientTask("Extruding...", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
ISize origSize = getImageDataSetChannel().getISize();
if (origSize.getZ() != 1 || newZSize < 1) {
throw new IllegalArgumentException("Extrude assumes starting with 2D and new Z size >= 1.");
}
UShortImage[][] newUnderLayImageArr = new UShortImage[initImageDataSetChannels.length][newZSize];
BufferedImage[] newROICompositeArr = new BufferedImage[newZSize];
for (int i = 0; i < newZSize; i++) {
for (int c = 0; c < initImageDataSetChannels.length; c++) {
// short[] zslice = new short[initImageDataSetChannels[c].getAllImages()[0].getPixels().length];
// System.arraycopy(initImageDataSetChannels[c].getAllImages()[0].getPixels(), 0, zslice, 0, zslice.length);
newUnderLayImageArr[c][i] = new UShortImage(// zslice,
initImageDataSetChannels[c].getAllImages()[0].getPixels().clone(), DEFAULT_ORIGIN, DEFAULT_EXTENT, initImageDataSetChannels[c].getAllImages()[0].getNumX(), initImageDataSetChannels[c].getAllImages()[0].getNumY(), 1);
}
newROICompositeArr[i] = new BufferedImage(roiComposite[0].getWidth(), roiComposite[0].getHeight(), BufferedImage.TYPE_BYTE_INDEXED, getContrastIndexColorModel());
System.arraycopy((byte[]) ((DataBufferByte) roiComposite[0].getRaster().getDataBuffer()).getData(), 0, (byte[]) ((DataBufferByte) newROICompositeArr[i].getRaster().getDataBuffer()).getData(), 0, origSize.getX() * origSize.getY());
}
for (int c = 0; c < initImageDataSetChannels.length; c++) {
initImageDataSetChannels[c] = new ImageDataset(newUnderLayImageArr[c], null, newZSize);
}
roiComposite = newROICompositeArr;
if (!(enhanceImageAmount == ROIMultiPaintManager.ENHANCE_NONE)) {
getClientTaskStatusSupport().setMessage("smoothing...");
}
updateAuxiliaryInfo(origSize, getClientTaskStatusSupport());
}
};
final AsynchClientTask updatePanelTask = getUpdateDisplayAfterCropTask();
ClientTaskDispatcher.dispatch(overlayEditorPanelJAI, new Hashtable<String, Object>(), new AsynchClientTask[] { extrudeTask, updatePanelTask }, false, false, null, true);
}
use of java.awt.image.DataBufferByte in project vcell by virtualcell.
the class ROIMultiPaintManager method resizeXYByte.
public static PlanarImage resizeXYByte(byte[] byteArr, int numX, int numY, Float scaleX, Float scaleY) {
BufferedImage bufferedImage = new BufferedImage(numX, numY, BufferedImage.TYPE_BYTE_INDEXED, getContrastIndexColorModel());
byte[] byteData = ((DataBufferByte) bufferedImage.getRaster().getDataBuffer()).getData();
System.arraycopy(byteArr, 0, byteData, 0, byteArr.length);
PlanarImage planarImage = ScaleDescriptor.create(bufferedImage, scaleX, scaleY, 0f, 0f, new InterpolationNearest(), null);
return planarImage;
// PaddedInfo paddedInfo = new PaddedInfo();
// paddedInfo.paddedArray = ((DataBufferByte)planarImage.getData().getDataBuffer()).getData();
// paddedInfo.paddedISize = new ISize(planarImage.getWidth(), planarImage.getHeight(), 1);
// return paddedInfo;
}
use of java.awt.image.DataBufferByte in project vcell by virtualcell.
the class OverlayEditorPanelJAI method saveUserChangesToROI.
public void saveUserChangesToROI() {
short[] roiPixels = getImagePane().getHighlightImageWritebackImageBuffer();
if (roiPixels != null) {
BufferedImage highlightImage = imagePane.getHighlightImage();
byte[] hiLiteArr = ((DataBufferByte) highlightImage.getRaster().getDataBuffer()).getData();
for (int i = 0; i < roiPixels.length; i++) {
roiPixels[i] = (hiLiteArr[i] == 0 ? 0 : (short) 0xffff);
}
}
}
use of java.awt.image.DataBufferByte in project vcell by virtualcell.
the class VFrap_OverlayEditorPanelJAI method createHighlightImageFromROI.
/**
* Method createHighlightImageFromROI.
* @return BufferedImage
*/
private BufferedImage createHighlightImageFromROI() {
int[] cmap = new int[256];
// colormap (grayscale)
for (int i = 0; i < 256; i += 1) {
if (i != 0) {
cmap[i] = 0xFF000000 | highlightColor.getRGB();
} else {
cmap[1] = 0xFF000000;
}
}
IndexColorModel indexColorModel = new java.awt.image.IndexColorModel(8, cmap.length, cmap, 0, false, /*false means NOT USE alpha*/
-1, /*NO transparent single pixel*/
java.awt.image.DataBuffer.TYPE_BYTE);
UShortImage roiImage = roi.getRoiImages()[getRoiImageIndex()];
int width = roiImage.getNumX();
int height = roiImage.getNumY();
BufferedImage hiLiteImage = new BufferedImage(width, height, BufferedImage.TYPE_BYTE_INDEXED, indexColorModel);
byte[] hiLiteArr = ((DataBufferByte) hiLiteImage.getRaster().getDataBuffer()).getData();
for (int i = 0; i < roiImage.getPixels().length; i++) {
hiLiteArr[i] = (roiImage.getPixels()[i] != 0 ? (byte) highlightColor.getRed() : 0);
}
return hiLiteImage;
}
Aggregations