use of cbit.vcell.VirtualMicroscopy.UShortImage in project vcell by virtualcell.
the class VFrap_ROIAssistPanel method forceROIValid.
private ROI forceROIValid(ROI validateROI) throws Exception {
if (validateROI.getROIName().equals(VFrap_ROISourceData.VFRAP_ROI_ENUM.ROI_BACKGROUND.name())) {
lastRegionInfos = null;
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
// }});
applyROIButton.setEnabled(true);
resolveROIButton.setEnabled(false);
fillVoidsButton.setEnabled(false);
}
});
return validateROI;
}
if (validateROI.getNonzeroPixelsCount() < 1) {
return validateROI;
}
//
// Remove pixels touching only at corners
//
short[] validatePixels = validateROI.getPixelsXYZ();
//
// Remove noise objects
//
lastRegionInfos = calculateRegionInfos(validatePixels);
Vector<RegionInfo> roiRegionInfoV = new Vector<RegionInfo>();
for (int i = 0; i < lastRegionInfos.length; i++) {
if (lastRegionInfos[i].getPixelValue() == 1) {
roiRegionInfoV.add(lastRegionInfos[i]);
}
// System.out.println(lastRegionInfos[i]);
}
// if(validateROI.getROIType().equals(RoiType.ROI_CELL) || validateROI.getROIType().equals(RoiType.ROI_BLEACHED)){
if (roiRegionInfoV.size() > 1) {
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
applyROIButton.setEnabled(false);
resolveROIButton.setEnabled(true);
fillVoidsButton.setEnabled(false);
}
});
} else {
final boolean hasInternalVoids = fillVoids(validatePixels, true);
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
// }});
lastRegionInfos = null;
applyROIButton.setEnabled(!hasInternalVoids);
resolveROIButton.setEnabled(false);
fillVoidsButton.setEnabled(hasInternalVoids);
}
});
}
UShortImage ushortImage = new UShortImage(validatePixels, validateROI.getRoiImages()[0].getOrigin(), validateROI.getRoiImages()[0].getExtent(), validateROI.getISize().getX(), validateROI.getISize().getY(), validateROI.getISize().getZ());
ROI newROI = new ROI(ushortImage, validateROI.getROIName());
if (newROI.compareEqual(validateROI)) {
return validateROI;
}
return newROI;
}
use of cbit.vcell.VirtualMicroscopy.UShortImage in project vcell by virtualcell.
the class VFrap_OverlayEditorPanelJAI method displaySpecialData.
public void displaySpecialData(short[] specialData, int width, int height) throws Exception {
if (specialData == null) {
forceImage();
return;
}
UShortImage specialUShortImage = new UShortImage(specialData, null, null, width, height, 1);
BufferedImage specialBufferedImage = createUnderlyingImage(specialUShortImage);
imagePane.setUnderlyingImage(specialBufferedImage, false, null);
}
use of cbit.vcell.VirtualMicroscopy.UShortImage in project vcell by virtualcell.
the class VFrap_OverlayEditorPanelJAI method getImage.
/**
* Gets the currently displayed image. * @return BufferedImage
*/
private BufferedImage getImage() {
if (imageDataset == null) {
return null;
}
int ndx = getImageIndex();
if (imageDataset == null || ndx >= imageDataset.getAllImages().length) {
return null;
}
UShortImage image = imageDataset.getAllImages()[ndx];
return createUnderlyingImage(image);
}
use of cbit.vcell.VirtualMicroscopy.UShortImage in project vcell by virtualcell.
the class OverlayEditorPanelJAI method getImage.
/**
* Gets the currently displayed image. * @return BufferedImage
*/
private BufferedImage getImage() {
if (imageDataset == null) {
return null;
}
int ndx = getImageIndex();
if (imageDataset == null || ndx >= imageDataset.getAllImages().length) {
return null;
}
UShortImage image = imageDataset.getAllImages()[ndx];
return createUnderlyingImage(image);
}
use of cbit.vcell.VirtualMicroscopy.UShortImage in project vcell by virtualcell.
the class ROIAssistPanel method createScaledTimeAverageData.
private void createScaledTimeAverageData() throws Exception {
int numTimes = dataToThreshold.getImageDataset().getSizeT();
long[] timeSum = new long[dataToThreshold.getImageDataset().getISize().getXYZ()];
for (int t = 0; t < numTimes; t++) {
int pixelIndex = 0;
for (int z = 0; z < dataToThreshold.getImageDataset().getSizeZ(); z++) {
UShortImage timePointDataImage = dataToThreshold.getImageDataset().getImage(z, 0, t);
for (int y = 0; y < timePointDataImage.getNumY(); y++) {
for (int x = 0; x < timePointDataImage.getNumX(); x++) {
timeSum[pixelIndex] += timePointDataImage.getPixel(x, y, 0) & 0x0000FFFF;
pixelIndex++;
}
}
}
}
roiTimeAverageDataShort = new short[timeSum.length];
for (int i = 0; i < timeSum.length; i++) {
roiTimeAverageDataShort[i] |= ((int) (timeSum[i] / numTimes)) & 0x0000FFFF;
}
scaleDataInPlace(roiTimeAverageDataShort);
}
Aggregations