Search in sources :

Example 6 with SourceDataInfo

use of cbit.image.SourceDataInfo in project vcell by virtualcell.

the class GeometrySummaryPanel method initGeometry.

/**
 * Comment
 */
private void initGeometry(Geometry arg1) {
    final boolean bSpatial = getGeometry() != null && getGeometry().getDimension() > 0;
    getImagePlaneManagerPanel1().setVisible(bSpatial);
    getJPanelOrigin().setVisible(bSpatial);
    getJPanelSize().setVisible(bSpatial);
    if (getGeometry() != null) {
        try {
            if (getGeometry().getGeometrySpec().getSampledImage().isDirty()) {
                return;
            }
            VCImage vcImage = getGeometry().getGeometrySpec().getSampledImage().getCurrentValue();
            byte[] pixels = vcImage.getPixels();
            DisplayAdapterService das = new DisplayAdapterService();
            das.setActiveScaleRange(new org.vcell.util.Range(0, 255));
            das.setValueDomain(new org.vcell.util.Range(0, 255));
            das.addColorModelForValues(DisplayAdapterService.createContrastColorModel(), DisplayAdapterService.createGraySpecialColors(), "Contrast");
            das.setActiveColorModelID("Contrast");
            int[] rgb = new int[pixels.length];
            for (int i = 0; i < rgb.length; i += 1) {
                rgb[i] = das.getColorFromIndex(pixels[i]);
            }
            SourceDataInfo sdi = new SourceDataInfo(SourceDataInfo.INT_RGB_TYPE, rgb, getGeometry().getExtent(), getGeometry().getOrigin(), new org.vcell.util.Range(0, 255), 0, vcImage.getNumX(), 1, vcImage.getNumY(), vcImage.getNumX(), vcImage.getNumZ(), vcImage.getNumX() * vcImage.getNumY());
            getImagePlaneManagerPanel1().setSourceDataInfo(sdi);
        } catch (Exception e) {
            PopupGenerator.showErrorDialog(GeometrySummaryPanel.this, e.getMessage(), e);
        }
    } else {
        getImagePlaneManagerPanel1().setSourceDataInfo(null);
    }
}
Also used : DisplayAdapterService(cbit.image.DisplayAdapterService) VCImage(cbit.image.VCImage) SourceDataInfo(cbit.image.SourceDataInfo) ImageException(cbit.image.ImageException)

Example 7 with SourceDataInfo

use of cbit.image.SourceDataInfo in project vcell by virtualcell.

the class GeometryViewer method refreshSourceDataInfo.

/**
 * connEtoM2:  (Geometry.this --> ImagePlaneManagerPanel1.sourceDataInfo)
 * @param value cbit.vcell.geometry.Geometry
 */
/* WARNING: THIS METHOD WILL BE REGENERATED. */
private void refreshSourceDataInfo() {
    if (getGeometry() == null) {
        return;
    }
    GeometrySpec geometrySpec = getGeometry().getGeometrySpec();
    if (geometrySpec.getSampledImage().isDirty()) {
        return;
    }
    VCImage sampledImage = geometrySpec.getSampledImage().getCurrentValue();
    try {
        SourceDataInfo sdi = new SourceDataInfo(SourceDataInfo.INDEX_TYPE, sampledImage.getPixels(), geometrySpec.getExtent(), geometrySpec.getOrigin(), null, 0, sampledImage.getNumX(), 1, sampledImage.getNumY(), sampledImage.getNumX(), sampledImage.getNumZ(), sampledImage.getNumX() * sampledImage.getNumY());
        getImagePlaneManagerPanel1().setSourceDataInfo(sdi);
    } catch (ImageException e) {
        e.printStackTrace();
        DialogUtils.showErrorDialog(this, e.getMessage());
    } catch (Exception e) {
        e.printStackTrace();
        DialogUtils.showErrorDialog(this, e.getMessage(), e);
    }
}
Also used : GeometrySpec(cbit.vcell.geometry.GeometrySpec) ImageException(cbit.image.ImageException) VCImage(cbit.image.VCImage) SourceDataInfo(cbit.image.SourceDataInfo) ImageException(cbit.image.ImageException)

Example 8 with SourceDataInfo

use of cbit.image.SourceDataInfo in project vcell by virtualcell.

the class DisplayImageOp method displayImage.

public void displayImage(final Image image, String title, WindowListener listener) {
    final ImagePlaneManagerPanel imagePanel = new ImagePlaneManagerPanel();
    double[] doublePixels = image.getDoublePixels();
    double minPixel = Double.MAX_VALUE;
    double maxPixel = -Double.MAX_VALUE;
    for (int i = 0; i < doublePixels.length; i++) {
        double pixel = doublePixels[i];
        doublePixels[i] = pixel;
        minPixel = Math.min(minPixel, pixel);
        maxPixel = Math.max(maxPixel, pixel);
    }
    Range newRange = new Range(minPixel, maxPixel);
    SourceDataInfo source = new SourceDataInfo(SourceDataInfo.RAW_VALUE_TYPE, doublePixels, image.getExtent(), image.getOrigin(), newRange, 0, image.getNumX(), 1, image.getNumY(), image.getNumX(), image.getNumZ(), image.getNumX() * image.getNumY());
    imagePanel.setDisplayAdapterServicePanelVisible(true);
    imagePanel.setCurveValueProvider(new CurveValueProvider() {

        @Override
        public void curveAdded(Curve curve) {
            System.out.println("called curveAdded(" + curve + "), do nothing for now");
        }

        @Override
        public void curveRemoved(Curve curve) {
            System.out.println("called curveRemoved(" + curve + ")");
        }

        @Override
        public String getCurveValue(CurveSelectionInfo csi) {
            System.out.println("called getCurveValue(CurveSelectionInfo " + csi);
            return null;
        }

        @Override
        public CurveSelectionInfo getInitalCurveSelection(int tool, Coordinate wc) {
            System.out.println("called getInitialCurveSelection(tool=" + tool + ", coord=" + wc + ")");
            return null;
        }

        @Override
        public boolean isAddControlPointOK(int tool, Coordinate wc, Curve addedToThisCurve) {
            System.out.println("called isAddControlPointOK");
            return true;
        }

        @Override
        public boolean providesInitalCurve(int tool, Coordinate wc) {
            System.out.println("called providesInitialCurve(tool=" + tool + " (TOOL_LINE=" + CurveEditorTool.TOOL_LINE + "), coord=" + wc);
            return false;
        }

        @Override
        public void setDescription(Curve curve) {
            System.out.println("called setDescription(" + curve + ")");
            curve.setDescription(CurveValueProvider.DESCRIPTION_VOLUME);
        }

        @Override
        public CurveSelectionInfo findChomboCurveSelectionInfoForPoint(CoordinateIndex ci) {
            System.out.println("called find ChomboCurveSelectionInfoForPoint(coord=" + ci + ")");
            return null;
        }
    });
    DisplayAdapterService das = imagePanel.getDisplayAdapterServicePanel().getDisplayAdapterService();
    das.setValueDomain(null);
    das.addColorModelForValues(DisplayAdapterService.createGrayColorModel(), DisplayAdapterService.createGraySpecialColors(), DisplayAdapterService.GRAY);
    das.addColorModelForValues(DisplayAdapterService.createBlueRedColorModel(), DisplayAdapterService.createBlueRedSpecialColors(), DisplayAdapterService.BLUERED);
    das.setActiveColorModelID(DisplayAdapterService.BLUERED);
    final JFrame jframe = new JFrame();
    jframe.setTitle(title);
    JPanel panel = new JPanel();
    panel.setLayout(new GridBagLayout());
    GridBagConstraints imageConstraints = new GridBagConstraints();
    imageConstraints.gridx = 0;
    imageConstraints.gridy = 0;
    imageConstraints.weightx = 1.0;
    imageConstraints.weighty = 1.0;
    imageConstraints.fill = GridBagConstraints.BOTH;
    panel.add(imagePanel, imageConstraints);
    JButton plotButton = new JButton("plot");
    plotButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            try {
                Curve curve = imagePanel.getCurveRenderer().getSelection().getCurve();
                VariableType variableType = VariableType.VOLUME;
                Curve samplerCurve = curve.getSampledCurve();
                samplerCurve.setDescription(curve.getDescription());
                VCImage vcImage = new VCImageUncompressed(null, new byte[image.getISize().getXYZ()], image.getExtent(), image.getISize().getX(), image.getISize().getY(), image.getISize().getZ());
                int dimension = 1 + (image.getISize().getY() > 0 ? 1 : 0) + (image.getISize().getZ() > 0 ? 1 : 0);
                RegionImage regionImage = new RegionImage(vcImage, dimension, image.getExtent(), image.getOrigin(), RegionImage.NO_SMOOTHING);
                CartesianMesh mesh = CartesianMesh.createSimpleCartesianMesh(image.getOrigin(), image.getExtent(), image.getISize(), regionImage);
                SpatialSelectionVolume ssVolume = new SpatialSelectionVolume(new CurveSelectionInfo(samplerCurve), variableType, mesh);
                String varName = "var";
                SymbolTableEntry[] symbolTableEntries = new SymbolTableEntry[] { new VolVariable(varName, null) };
                PlotData plotData = getLineScan(ssVolume, image, mesh);
                PlotPane plotPane = new PlotPane();
                DataSymbolMetadataResolver resolver = null;
                Plot2D plot2D = new Plot2D(symbolTableEntries, resolver, new String[] { varName }, new PlotData[] { plotData }, new String[] { "Values along curve", "Distance (\u00b5m)", "[" + varName + "]" });
                plotPane.setPlot2D(plot2D);
                DialogUtils.showComponentCloseDialog(jframe, plotPane, "plot");
            } catch (ImageException | IOException | DataAccessException | MathException e1) {
                e1.printStackTrace();
            }
        }
    });
    GridBagConstraints plotButtonConstraints = new GridBagConstraints();
    plotButtonConstraints.gridx = 0;
    plotButtonConstraints.gridy = 1;
    panel.add(plotButton, plotButtonConstraints);
    jframe.getContentPane().add(panel);
    jframe.setSize(500, 500);
    jframe.addWindowListener(listener);
    jframe.setVisible(true);
    imagePanel.setSourceDataInfo(source);
}
Also used : DisplayAdapterService(cbit.image.DisplayAdapterService) JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) GridBagLayout(java.awt.GridBagLayout) ActionEvent(java.awt.event.ActionEvent) ImagePlaneManagerPanel(cbit.image.gui.ImagePlaneManagerPanel) JButton(javax.swing.JButton) VCImage(cbit.image.VCImage) SourceDataInfo(cbit.image.SourceDataInfo) CoordinateIndex(org.vcell.util.CoordinateIndex) JFrame(javax.swing.JFrame) PlotData(cbit.plot.PlotData) DataSymbolMetadataResolver(cbit.vcell.solver.SimulationModelInfo.DataSymbolMetadataResolver) VariableType(cbit.vcell.math.VariableType) VolVariable(cbit.vcell.math.VolVariable) Curve(cbit.vcell.geometry.Curve) VCImageUncompressed(cbit.image.VCImageUncompressed) Range(org.vcell.util.Range) CartesianMesh(cbit.vcell.solvers.CartesianMesh) CurveValueProvider(cbit.vcell.simdata.gui.CurveValueProvider) ActionListener(java.awt.event.ActionListener) Coordinate(org.vcell.util.Coordinate) SpatialSelectionVolume(cbit.vcell.simdata.SpatialSelectionVolume) RegionImage(cbit.vcell.geometry.RegionImage) PlotPane(cbit.plot.gui.PlotPane) Plot2D(cbit.plot.Plot2D) CurveSelectionInfo(cbit.vcell.geometry.CurveSelectionInfo)

Example 9 with SourceDataInfo

use of cbit.image.SourceDataInfo in project vcell by virtualcell.

the class DataSymbolsSpecPanel method setDataSymbol.

// public void createDataSymbol() throws Exception, UserCancelException{
// final int VFRAP_DATASET = 0;
// final int VFRAP_SPECIALS = 1;
// final int ASSOCIATE_EXISTING_FD = 2;
// final int POINT_SPREAD_FUNCTION = 3;
// final int IMAGE_FILE = 4;
// final int COPY_FROM_BIOMODEL = 5;
// int[] dataSymbolSource = null;
// 
// String[][] choices = new String[][] {{ADD_VFRAP_DATASET_MENU},{ADD_VFRAP_SPECIALS_MENU},{ADD_ASSOCIATE_EXISTING_FD_MENU},
// {ADD_PSF_MENU},{ADD_IMAGE_FILE_MENU},{ADD_COPY_FROM_BIOMODEL_MENU} };
// 
// dataSymbolSource = DialogUtils.showComponentOKCancelTableList(
// getComponent(),
// "Choose a source for the data symbol.",
// new String[] {"Available Sources:"},
// choices, ListSelectionModel.SINGLE_SELECTION);
// 
// if(dataSymbolSource[0] == VFRAP_DATASET){
// getDataSymbolsPanel().addVFrapOriginalImages();
// }else if(dataSymbolSource[0] == VFRAP_SPECIALS){
// getDataSymbolsPanel().addVFrapDerivedImages();
// }else if(dataSymbolSource[0] == ASSOCIATE_EXISTING_FD){
// Component requesterComponent = DataSymbolsSpecPanel.this;
// DocumentWindow documentWindow = (DocumentWindow)BeanUtils.findTypeParentOfComponent(requesterComponent, DocumentWindow.class);
// documentWindow.getTopLevelWindowManager().getRequestManager().showFieldDataWindow(new FieldDataWindowManager.DataSymbolCallBack() {
// public void createDataSymbol(ExternalDataIdentifier dataSetID,
// String fieldDataVarName, VariableType fieldDataVarType,
// double fieldDataVarTime) {
// 
// System.out.println(dataSetID+" "+fieldDataVarName+" "+fieldDataVarType+" "+fieldDataVarTime);
// // ex: incomplete 51780592 danv(26766043)      fluor     Volume_VariableType     23.680419921875
// 
// DecimalFormat df = new  DecimalFormat("###000.00");		// max time interval we can display is about 11 days
// String fluorName = fieldDataVarName + "_" + df.format(fieldDataVarTime).substring(0, df.format(fieldDataVarTime).indexOf(".")) + "s" + df.format(fieldDataVarTime).substring(1+df.format(fieldDataVarTime).indexOf(".")) + "_" + dataSetID.getName();
// // TODO:  symbol names may not be unique, must check for unicity and prompt the user
// FieldDataSymbol dataSymbol = new FieldDataSymbol(fluorName, DataSymbolType.GENERIC_SYMBOL,
// getSimulationContext().getDataContext(), VCUnitDefinition.UNIT_TBD,
// dataSetID,
// fieldDataVarName, fieldDataVarType.getTypeName(), fieldDataVarTime);
// getSimulationContext().getDataContext().addDataSymbol(dataSymbol);
// 
// }
// });
// }else if(dataSymbolSource[0] == POINT_SPREAD_FUNCTION){
// PointSpreadFunctionManagement psfManager = new PointSpreadFunctionManagement(DataSymbolsSpecPanel.this,
// getSimulationContext());
// psfManager.importPointSpreadFunction();
// }else if(dataSymbolSource[0] == IMAGE_FILE){
// throw new RuntimeException("Option not yet implemented.");
// }else if(dataSymbolSource[0] == COPY_FROM_BIOMODEL){
// throw new RuntimeException("Option not yet implemented.");
// }else{
// throw new IllegalArgumentException("Error selecting data symbol, Unknown Source type " + dataSymbolSource[0]);
// }
// }
public void setDataSymbol(Object object) {
    if (object == null) {
        // TODO: display empty image
        return;
    }
    if (((DataSymbol) object).equals(ivjCurrentSymbol)) {
        return;
    } else {
        ivjCurrentSymbol = (DataSymbol) object;
    }
    // manage checkbox status depending on type of current data symbol
    DataSymbolType dsType = ivjCurrentSymbol.getDataSymbolType();
    switch(dsType) {
        case GENERIC_SYMBOL:
            getChckbxPointSpreadFunction().setEnabled(true);
            getChckbxPointSpreadFunction().setSelected(false);
            break;
        case POINT_SPREAD_FUNCTION:
            getChckbxPointSpreadFunction().setEnabled(true);
            getChckbxPointSpreadFunction().setSelected(true);
            break;
        default:
            getChckbxPointSpreadFunction().setEnabled(false);
            getChckbxPointSpreadFunction().setSelected(false);
            break;
    }
    // displays iconized image for the current (field?) data symbol
    getImagePlaneManagerPanel().setMode(ImagePaneModel.MESH_MODE);
    int w = Integer.valueOf(30).intValue() + 5 * (countW % 5);
    int h = Integer.valueOf(20).intValue() + 3 * (countH % 7);
    String type = "double";
    System.out.println("  " + w + ", " + h);
    SourceDataInfo sdi = ImagePaneScrollerTest.getExampleSDI(type, w, h);
    getImagePlaneManagerPanel().setSourceDataInfo(sdi);
    countW++;
    countH++;
}
Also used : DataSymbol(cbit.vcell.data.DataSymbol) DataSymbolType(cbit.vcell.data.DataSymbol.DataSymbolType) SourceDataInfo(cbit.image.SourceDataInfo)

Example 10 with SourceDataInfo

use of cbit.image.SourceDataInfo in project vcell by virtualcell.

the class PDEOffscreenRenderer method getScaledRGBVolume.

private BufferedImage getScaledRGBVolume(CartesianMesh mesh, int meshMode, int imageScale, boolean bBackground) {
    Dimension dim = FormatSpecificSpecs.getMeshDimensionUnscaled(getNormalAxis(), getServerPDEDataContext().getCartesianMesh());
    int width = (int) dim.getWidth();
    int height = (int) dim.getHeight();
    double[] volumeData = new double[width * height];
    if (!bBackground) {
        // if(bNeedsDefaultScaling){setDefaultScaling();}
        double notInDomainValue = getDisplayAdapterService().getValueDomain().getMin() - 1.0;
        double[] values = getServerPDEDataContext().getDataValues();
        int[] dataIndices = getServerPDEDataContext().getCartesianMesh().getVolumeSliceIndices(getNormalAxis(), getSlice());
        for (int i = 0; i < dataIndices.length; i++) {
            double value = values[dataIndices[i]];
            if (domainValid != null) {
                if (domainValid.get(dataIndices[i]) || domainValid.isEmpty()) {
                    volumeData[i] = value;
                } else {
                    volumeData[i] = notInDomainValue;
                }
            } else {
                volumeData[i] = value;
            }
        }
    }
    SourceDataInfo sourceDataInfo = new SourceDataInfo(SourceDataInfo.RAW_VALUE_TYPE, volumeData, mesh.getExtent(), mesh.getOrigin(), new Range(0, 1), 0, width, 1, height, width, 1, 0);
    ImagePaneModel imagePaneModel = new ImagePaneModel();
    imagePaneModel.setSourceData(sourceDataInfo);
    imagePaneModel.setBackgroundColor(Color.black);
    imagePaneModel.setDisplayAdapterService(getDisplayAdapterService());
    // getDisplayAdapterService().setActiveScaleRange(new Range(0,1));
    imagePaneModel.setMode(meshMode);
    imagePaneModel.setZoom(imageScale);
    imagePaneModel.setViewport(new Rectangle(imagePaneModel.getScaledLength(width), imagePaneModel.getScaledLength(height)));
    imagePaneModel.updateViewPortImage();
    if (bBackground) {
        int[] internalBuffer = ((DataBufferInt) (imagePaneModel.getViewPortImage().getRaster().getDataBuffer())).getData();
        Arrays.fill(internalBuffer, getDisplayAdapterService().getSpecialColors()[DisplayAdapterService.NULL_COLOR_OFFSET]);
    }
    BufferedImage bufferedImage = imagePaneModel.getViewPortImage();
    imagePaneModel.setDisplayAdapterService(null);
    return bufferedImage;
}
Also used : ImagePaneModel(cbit.image.ImagePaneModel) Rectangle(java.awt.Rectangle) Dimension(java.awt.Dimension) DataBufferInt(java.awt.image.DataBufferInt) SourceDataInfo(cbit.image.SourceDataInfo) Range(org.vcell.util.Range) BufferedImage(java.awt.image.BufferedImage)

Aggregations

SourceDataInfo (cbit.image.SourceDataInfo)18 Range (org.vcell.util.Range)5 DisplayAdapterService (cbit.image.DisplayAdapterService)3 ImageException (cbit.image.ImageException)3 VCImage (cbit.image.VCImage)3 UShortImage (cbit.vcell.VirtualMicroscopy.UShortImage)2 VariableType (cbit.vcell.math.VariableType)2 DataOperationResults (cbit.vcell.simdata.DataOperationResults)2 CartesianMesh (cbit.vcell.solvers.CartesianMesh)2 ArrayList (java.util.ArrayList)2 ImageTimeSeries (org.vcell.vmicro.workflow.data.ImageTimeSeries)2 ImagePaneModel (cbit.image.ImagePaneModel)1 ImagePlaneManager (cbit.image.ImagePlaneManager)1 VCImageUncompressed (cbit.image.VCImageUncompressed)1 ImagePlaneManagerPanel (cbit.image.gui.ImagePlaneManagerPanel)1 Plot2D (cbit.plot.Plot2D)1 PlotData (cbit.plot.PlotData)1 PlotPane (cbit.plot.gui.PlotPane)1 ImageDataset (cbit.vcell.VirtualMicroscopy.ImageDataset)1 AsynchClientTask (cbit.vcell.client.task.AsynchClientTask)1