Login  Register

Re: histogram of a surrounding sphere

Posted by Thomas Boudier on Feb 21, 2009; 5:31pm
URL: http://imagej.273.s1.nabble.com/histogram-of-a-surrounding-sphere-tp3693546p3693547.html

Hi,

You can use my ij3d API, here a simple plugin  to do that (beware a lot
of text !!) :

compile it using -cp ij.jar and ij3d-bin.jar
http://imagejdocu.tudor.lu/doku.php?id=plugin:morphology:3d_binary_morphological_filters:start

Hope this helps, tell me if you need more explanations.

Thomas



import ij.*;
import ij.gui.*;
import ij.measure.*;
import ij.plugin.*;
import ij.plugin.filter.*;
import ij.process.*;

import ij3d.image3d.*;
import ij3d.utils.*;

import java.awt.*;
import java.awt.event.ItemEvent;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.text.*;
import java.util.Enumeration;
import java.util.Vector;
/**
 * Histogram for each pixel in 3D
 *
 *@author     Thomas BOUDIER
 *@created    avril 2003
 */
public class HistoPixel3D_ implements PlugInFilter {
    ImagePlus imp;
    float rad;


    /**
     *  Main processing method for the Median3D_ object
     *
     *@param  ip  Description of the Parameter
     */
    public void run(ImageProcessor ip) {
        rad = 5;
        if (Dialogue()) {
            TabUtil tab;
            IntImage3D col = new IntImage3D(imp.getStack());
            IJ.resetEscape();
            for (int k = 0; k < col.getSizez(); k++) {
                if (IJ.escapePressed()) {
                    break;
                }
                IJ.showStatus("3D Histo Pixel : " + (int) (100 * k /
col.getSizez()) + "%");
                for (int j = 0; j < col.getSizey(); j++) {
                    for (int i = 0; i < col.getSizex(); i++) {
                        tab = col.getNeighborhoodSphere(i, j, k, rad,
rad, rad);
                        IJ.write("" + tab);
                    }
                }
            }

        }
    }


    /**
     *  Description of the Method
     *
     *@return    Description of the Return Value
     */
    private boolean Dialogue() {
        GenericDialog gd = new GenericDialog("3D Histo Pixel");
        gd.addNumericField("Radius", rad, 0);
        gd.showDialog();
        rad = (int) gd.getNextNumber();
        return (!gd.wasCanceled());
    }


    /**
     *  Description of the Method
     *
     *@param  arg  Description of the Parameter
     *@param  imp  Description of the Parameter
     *@return      Description of the Return Value
     */
    public int setup(String arg, ImagePlus imp) {
        this.imp = imp;
        return DOES_8G + DOES_16 + NO_CHANGES;
    }

}


 
> Hi,In a 3D 8-bit stack (comes from tomography experiment), I would like to have for each point the histogram of the grey scale value of the surrounding voxels contained in a sphere (of 5 voxel radius for example) centered on the point.Any help is warmly welcome.Thank you
> Milan
> _________________________________________________________________
> Découvrez la nouvelle génération des servives de Windows Live
> http://download.live.com
>
>  


--
/*****************************************************/
 Thomas Boudier, MCU Université Pierre et Marie Curie
 UMR 7101 / IFR 83. Bat A 328, Campus Jussieu
 Tél : 01 44 27 35 78  Fax : 01 44 27 25 08
/*****************************************************/