Search in sources :

Example 11 with UShortImage

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;
}
Also used : RegionInfo(cbit.vcell.geometry.RegionImage.RegionInfo) UShortImage(cbit.vcell.VirtualMicroscopy.UShortImage) Vector(java.util.Vector) ROI(cbit.vcell.VirtualMicroscopy.ROI)

Example 12 with UShortImage

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);
}
Also used : UShortImage(cbit.vcell.VirtualMicroscopy.UShortImage) BufferedImage(java.awt.image.BufferedImage)

Example 13 with UShortImage

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);
}
Also used : UShortImage(cbit.vcell.VirtualMicroscopy.UShortImage) Point(java.awt.Point)

Example 14 with UShortImage

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);
}
Also used : UShortImage(cbit.vcell.VirtualMicroscopy.UShortImage) Point(java.awt.Point)

Example 15 with UShortImage

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);
}
Also used : UShortImage(cbit.vcell.VirtualMicroscopy.UShortImage)

Aggregations

UShortImage (cbit.vcell.VirtualMicroscopy.UShortImage)98 ROI (cbit.vcell.VirtualMicroscopy.ROI)26 ImageDataset (cbit.vcell.VirtualMicroscopy.ImageDataset)20 Point (java.awt.Point)16 File (java.io.File)14 Extent (org.vcell.util.Extent)13 ImageTimeSeries (org.vcell.vmicro.workflow.data.ImageTimeSeries)12 Origin (org.vcell.util.Origin)10 ImageException (cbit.image.ImageException)9 Element (org.jdom.Element)9 DataBufferByte (java.awt.image.DataBufferByte)8 RowColumnResultSet (cbit.vcell.math.RowColumnResultSet)7 ArrayList (java.util.ArrayList)7 ISize (org.vcell.util.ISize)7 FloatImage (cbit.vcell.VirtualMicroscopy.FloatImage)6 ClientTaskStatusSupport (org.vcell.util.ClientTaskStatusSupport)6 UserCancelException (org.vcell.util.UserCancelException)6 ProfileDataElement (org.vcell.optimization.ProfileDataElement)5 ImportRawTimeSeriesFromVFrapOp (org.vcell.vmicro.op.ImportRawTimeSeriesFromVFrapOp)5 OptContext (org.vcell.vmicro.workflow.data.OptContext)5