Search in sources :

Example 41 with UShortImage

use of cbit.vcell.VirtualMicroscopy.UShortImage in project vcell by virtualcell.

the class MicroscopyXmlReader method getImageDataset.

/**
 * This method returns a Biomodel object from a XML Element.
 * Creation date: (3/13/2001 12:35:00 PM)
 * @param param org.jdom.Element
 * @return cbit.vcell.biomodel.BioModel
 * @throws XmlParseException
 */
private ImageDataset getImageDataset(Element param, ClientTaskStatusSupport progressListener) throws XmlParseException {
    List<Element> ushortImageElementList = param.getChildren(MicroscopyXMLTags.UShortImageTag);
    Iterator<Element> imageElementIter = ushortImageElementList.iterator();
    UShortImage[] images = new UShortImage[ushortImageElementList.size()];
    // added in Feb 2008, for counting loading progress
    int imageSize = ushortImageElementList.size();
    int imageCount = 0;
    while (imageElementIter.hasNext()) {
        images[imageCount++] = getUShortImage(imageElementIter.next());
        if (progressListener != null) {
            progressListener.setProgress((int) ((imageCount * 100.0) / imageSize));
        }
    }
    Element timeStampListElement = param.getChild(MicroscopyXMLTags.TimeStampListTag);
    double[] timestamps = null;
    if (timeStampListElement != null) {
        String timeStampListText = timeStampListElement.getTextTrim();
        StringTokenizer tokens = new StringTokenizer(timeStampListText, ",\n\r\t ", false);
        ArrayList<Double> times = new ArrayList<Double>();
        while (tokens.hasMoreTokens()) {
            String token = tokens.nextToken();
            times.add(Double.parseDouble(token));
        }
        timestamps = new double[times.size()];
        for (int i = 0; i < timestamps.length; i++) {
            timestamps[i] = times.get(i);
        }
    }
    int numTimeSteps = (timestamps != null) ? (timestamps.length) : (1);
    int numZ = images.length / numTimeSteps;
    ImageDataset imageDataset = new ImageDataset(images, timestamps, numZ);
    return imageDataset;
}
Also used : ImageDataset(cbit.vcell.VirtualMicroscopy.ImageDataset) Element(org.jdom.Element) ArrayList(java.util.ArrayList) UShortImage(cbit.vcell.VirtualMicroscopy.UShortImage) StringTokenizer(java.util.StringTokenizer)

Example 42 with UShortImage

use of cbit.vcell.VirtualMicroscopy.UShortImage in project vcell by virtualcell.

the class ROIMultiPaintManager method smoothImageDataset.

private ImageDataset[] smoothImageDataset(ImageDataset[] origImageDatasetChannels, int enhanceImageAmount, ClientTaskStatusSupport clientTaskStatusSupport) throws Exception {
    if (enhanceImageAmount == ROIMultiPaintManager.ENHANCE_NONE) {
        return null;
    }
    ImageDataset[] smoothedImageDatasetChannels = new ImageDataset[origImageDatasetChannels.length];
    int allCount = origImageDatasetChannels.length * origImageDatasetChannels[0].getSizeZ();
    int progress = 0;
    for (int c = 0; c < origImageDatasetChannels.length; c++) {
        UShortImage[] smoothedZSections = new UShortImage[origImageDatasetChannels[c].getISize().getZ()];
        // *2+1;
        int radius = enhanceImageAmount;
        // int[] divideTable = BoxBlurFilter.createDivideTable(radius);
        short[] intermediateArr = new short[origImageDatasetChannels[c].getAllImages()[0].getPixels().length];
        for (int z = 0; z < origImageDatasetChannels[c].getAllImages().length; z++) {
            smoothedZSections[z] = new UShortImage(new short[origImageDatasetChannels[c].getISize().getX() * origImageDatasetChannels[c].getISize().getY()], ROIMultiPaintManager.DEFAULT_ORIGIN, ROIMultiPaintManager.DEFAULT_EXTENT, origImageDatasetChannels[c].getISize().getX(), origImageDatasetChannels[c].getISize().getY(), 1);
            short[] enhancedData = smoothedZSections[z].getPixels();
            short[] roiSourceData = origImageDatasetChannels[c].getAllImages()[z].getPixels();
            BoxBlurFilter.blur(roiSourceData, intermediateArr, origImageDatasetChannels[c].getISize().getX(), origImageDatasetChannels[c].getISize().getY(), radius);
            BoxBlurFilter.blur(intermediateArr, enhancedData, origImageDatasetChannels[c].getISize().getY(), origImageDatasetChannels[c].getISize().getX(), radius);
            if (clientTaskStatusSupport != null) {
                if (clientTaskStatusSupport.isInterrupted()) {
                    return null;
                }
                progress++;
                clientTaskStatusSupport.setProgress(progress * 100 / allCount);
            }
        }
        ImageDataset smoothedImageDataset = new ImageDataset(smoothedZSections, new double[] { 0 }, origImageDatasetChannels[c].getISize().getZ());
        smoothedImageDatasetChannels[c] = smoothedImageDataset;
    }
    return smoothedImageDatasetChannels;
}
Also used : ImageDataset(cbit.vcell.VirtualMicroscopy.ImageDataset) UShortImage(cbit.vcell.VirtualMicroscopy.UShortImage) Point(java.awt.Point)

Example 43 with UShortImage

use of cbit.vcell.VirtualMicroscopy.UShortImage in project vcell by virtualcell.

the class ROIMultiPaintManager method applyHighlightToROI.

private void applyHighlightToROI(ROIMultiPaintManager.ComboboxROIName currentComboboxROIName, boolean bOverWrite) {
    UShortImage[] roiZ = overlayEditorPanelJAI.getHighliteInfo().getRoiImages();
    // Update composite ROI
    int roiColorIndex = currentComboboxROIName.getContrastColorIndex();
    for (int i = 0; i < roiZ.length; i++) {
        short[] pixels = roiZ[i].getPixels();
        byte[] compositePixels = ((DataBufferByte) roiComposite[i].getRaster().getDataBuffer()).getData();
        for (int j = 0; j < pixels.length; j++) {
            if (pixels[j] != 0) {
                compositePixels[j] = (bOverWrite ? (byte) roiColorIndex : (compositePixels[j] == 0 ? (byte) roiColorIndex : compositePixels[j]));
            }
        }
    }
    overlayEditorPanelJAI.setAllROICompositeImage(roiComposite, OverlayEditorPanelJAI.FRAP_DATA_UPDATEROI_WITHHIGHLIGHT_PROPERTY);
    overlayEditorPanelJAI.setHighliteInfo(null, OverlayEditorPanelJAI.FRAP_DATA_UPDATEROI_WITHHIGHLIGHT_PROPERTY);
}
Also used : UShortImage(cbit.vcell.VirtualMicroscopy.UShortImage) DataBufferByte(java.awt.image.DataBufferByte) Point(java.awt.Point)

Example 44 with UShortImage

use of cbit.vcell.VirtualMicroscopy.UShortImage in project vcell by virtualcell.

the class ROIMultiPaintManager method resizeImpl.

private void resizeImpl(ResizeInfo resizeInfo, ClientTaskStatusSupport clientTaskStatusSupport) throws Exception {
    resizeImpl0(resizeInfo, (bHasOriginalData ? initImageDataSetChannels : null), roiComposite);
    ISize newISize = resizeInfo.getNewSize();
    ISize oldISize = resizeInfo.getOriginalSize();
    Extent resizeExtent = createResizeExtent(originalExtent, oldISize, newISize);
    if (bHasOriginalData) {
        for (int c = 0; c < initImageDataSetChannels.length; c++) {
            UShortImage[] zImageSet = new UShortImage[newISize.getZ()];
            for (int z = 0; z < zImageSet.length; z++) {
                zImageSet[z] = new UShortImage(resizeInfo.underlayC[c][z], originalOrigin, resizeExtent, newISize.getX(), newISize.getY(), 1);
            }
            initImageDataSetChannels[c] = new ImageDataset(zImageSet, new double[] { 0.0 }, newISize.getZ());
        }
    } else {
        initImageDataSet(null, newISize);
    }
    roiComposite = resizeInfo.roiComposite;
    updateAuxiliaryInfo(originalISize, clientTaskStatusSupport);
}
Also used : ImageDataset(cbit.vcell.VirtualMicroscopy.ImageDataset) Extent(org.vcell.util.Extent) ISize(org.vcell.util.ISize) UShortImage(cbit.vcell.VirtualMicroscopy.UShortImage) Point(java.awt.Point)

Example 45 with UShortImage

use of cbit.vcell.VirtualMicroscopy.UShortImage in project vcell by virtualcell.

the class ROIMultiPaintManager method getNonZeroBoundingBox.

private ROIMultiPaintManager.Crop3D getNonZeroBoundingBox(boolean bUseROI) {
    Rectangle bounding2D = null;
    int lowZ = Integer.MAX_VALUE;
    int highZ = -1;
    if (bUseROI) {
        int lowX = Integer.MAX_VALUE;
        int lowY = Integer.MAX_VALUE;
        int highX = -1;
        int highY = -1;
        for (int z = 0; z < roiComposite.length; z++) {
            int xyIndex = 0;
            byte[] zSectData = ((DataBufferByte) roiComposite[z].getRaster().getDataBuffer()).getData();
            for (int y = 0; y < roiComposite[0].getHeight(); y++) {
                for (int x = 0; x < roiComposite[0].getWidth(); x++) {
                    if (zSectData[xyIndex] != 0) {
                        lowX = Math.min(lowX, x);
                        lowY = Math.min(lowY, y);
                        highX = Math.max(highX, x);
                        highY = Math.max(highY, y);
                        lowZ = Math.min(lowZ, z);
                        ;
                        highZ = Math.max(highZ, z);
                    }
                    xyIndex++;
                }
            }
        }
        if (lowX != Integer.MAX_VALUE) {
            bounding2D = new Rectangle(lowX, lowY, highX - lowX + 1, highY - lowY + 1);
        }
    } else {
        UShortImage[] images = getImageDataSetChannel().getAllImages();
        for (int z = 0; z < images.length; z++) {
            Rectangle boundingRect = images[z].getNonzeroBoundingBox();
            if (boundingRect != null) {
                lowZ = Math.min(lowZ, z);
                ;
                highZ = Math.max(highZ, z);
                if (bounding2D == null) {
                    bounding2D = boundingRect;
                } else {
                    bounding2D = bounding2D.union(boundingRect);
                }
            }
        }
    }
    if (bounding2D == null) {
        return null;
    }
    ROIMultiPaintManager.Crop3D bounding3D = new ROIMultiPaintManager.Crop3D();
    bounding3D.setBounds(bounding2D.x, bounding2D.y, lowZ, bounding2D.width, bounding2D.height, highZ - lowZ + 1);
    return bounding3D;
}
Also used : Rectangle(java.awt.Rectangle) UShortImage(cbit.vcell.VirtualMicroscopy.UShortImage) DataBufferByte(java.awt.image.DataBufferByte) Point(java.awt.Point)

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