[Insight-users] Raw images reader

Thibault Varacca thibault.varacca at gmail.com
Tue Apr 30 03:20:22 EDT 2013


Hello,
It's ok, the output of the filter is binary.
I want to do some meshing with simpleitk from my segmented images but i
didn't see any meshfilter method.?
Here is my code wich works great while visualizing with imageJ's volume
viewer:

public class ImageReader {

    private static String inputFilename;
    private static String outputFilename;

    private static VectorUInt32 seedList = new VectorUInt32(3);
    private static Vector<String> names = new Vector<String>();

    private static ImageFileReader reader = new ImageFileReader();
    private static ImageFileWriter writer = new ImageFileWriter();

    private static ConnectedThresholdImageFilter filter = new
ConnectedThresholdImageFilter();
    // private static CastImageFilter cast = new CastImageFilter();
    private static BinaryErodeImageFilter erode = new
BinaryErodeImageFilter();
    private static BinaryDilateImageFilter dilate = new
BinaryDilateImageFilter();
    private static MedianImageFilter median = new MedianImageFilter();

    private static Image input = new Image(128, 128, 128,
            PixelIDValueEnum.sitkFloat32);
    private static Image output = new Image(128, 128, 128,
            PixelIDValueEnum.sitkFloat32);

    public static void main(String[] args) {

        int m = 0;
        names.clear();
        names.add(".xy.mhd");
        names.add(".xz.mhd");
        names.add(".yz.mhd");
        for (String i : names) {

            inputFilename = "fdk" + names.get(m);
            outputFilename = "output_cube" + names.get(m);
            reader.setFileName(inputFilename);
            writer.setFileName(outputFilename);

            /* valeurs de seuil */
            filter.setLower(0.00085);
            filter.setUpper(5);
            filter.setReplaceValue((short) 1);

            /* radius erosion / dilatation */
            erode.setKernelRadius(3);
            erode.setBackgroundValue(0.00085);
            erode.setForegroundValue(0.004);
            dilate.setKernelRadius(2);

            /* median */
            median.setRadius(3);

            /* seed points */
            seedList.clear();
            seedList.push_back(60);
            seedList.push_back(60);
            seedList.push_back(60);
            filter.setSeed(seedList);

            input = reader.execute();

            caracteristics(input, inputFilename);

            output = filter.execute(input);

            // output = dilate.execute(output);
            // output = median.execute(output);
            // erode.setKernelRadius(2);
            // dilate.setKernelRadius(2);
            // output = erode.execute(output);
            // output = dilate.execute(output);

            /* conversion float 32 bit */
            // cast.setOutputPixelType(PixelIDValueEnum.sitkFloat32);
            // output = cast.execute(output);

            writer.execute(output);
            caracteristics(output, outputFilename);
            m++;
        }
    }

    public static void caracteristics(Image image, String fn) {
        System.out.println("Filename: " + fn + " Dimension: "
                + image.getDimension() + " Type: "
                + image.getPixelIDTypeAsString() + " PixelID "
                + image.getPixelIDValue());
    }
}

Regards,


2013/4/29 Bradley Lowekamp <blowekamp at mail.nih.gov>

> Hello Thibault,
>
> That is really not enough information for anyone to be able to help you.
>
> Please provide a code snippet of what you tried to do. What do you expect
> the result to be, and what did you get as output? Also how did you examine
> your output?
>
> Also keep in mind the standard SimpleITK representation of a binary image
> output ( frequently from threshold based segmentations ) is an unint8_t
> image of 0s and 1s. Many images viewers will appear to just show a black
> image when the content is actually there.
>
> Brad
>
> On Apr 29, 2013, at 4:19 AM, Thibault Varacca <thibault.varacca at gmail.com>
> wrote:
>
> I tried to apply CastImageFilter 8bit -> 32 bit float but nothing worked
> ...
>
>
> 2013/4/29 Thibault Varacca <thibault.varacca at gmail.com>
>
>> Hi,
>> yes it works better ...
>> I have also another problem:  i have a 32-bit float image in input and
>> the filter generates an image of 8-bit unsigned integer. I want to have
>> 32-bit float in output.
>> Any way to do this?
>> Thanks !
>>
>>
>> 2013/4/26 Bradley Lowekamp <blowekamp at mail.nih.gov>
>>
>>> Hello,
>>>
>>> It appears you are not actually setting the seeds to the filter. There
>>> are two methods to choose from in C++:
>>>
>>> Self & SetSeed (std::vector< unsigned int > idx)
>>> Self & SetSeedList (std::vector< std::vector< unsigned int > > t)
>>>
>>> What you have as variable "seedList" is really just a single seed. In
>>> Java the types of the arguments for the above methods should
>>> be VectorUInt32, and VectorUIntList respectfully. You should be able to use
>>> the first one with your current variable.
>>>
>>> Brad
>>>
>>>
>>> On Apr 26, 2013, at 10:48 AM, Thibault Varacca <
>>> thibault.varacca at gmail.com> wrote:
>>>
>>> Ok the .mhd way to do this worked great.
>>>
>>> I have to do 3D segmentation on raw images. I tryed to do this with the
>>> ThresholdImageFilter but all my values are at zero after applying the
>>> filter ...
>>> My Raw images are Float32 3D 128x128x128, here is my code :
>>>
>>> import org.itk.simple.ConnectedThresholdImageFilter;
>>> import org.itk.simple.Image;
>>> import org.itk.simple.ImageFileReader;
>>> import org.itk.simple.ImageFileWriter;
>>> import org.itk.simple.VectorUInt32;
>>>
>>> public class ImageReader {
>>>
>>>     private static String inputFilename = "fdk.xy.mhd";
>>>     private static String outputFilename = "output.mhd";
>>>
>>>     public static void main(String[] args) {
>>>
>>>         VectorUInt32 seedList = new VectorUInt32(3);
>>>         ImageFileReader reader = new ImageFileReader();
>>>         ImageFileWriter writer = new ImageFileWriter();
>>>         ConnectedThresholdImageFilter filter = new
>>> ConnectedThresholdImageFilter();
>>>
>>>         reader.setFileName(inputFilename);
>>>         writer.setFileName(outputFilename);
>>>
>>>         Image input = reader.execute();
>>>
>>>         /* valeurs de seuil */
>>>         filter.setLower(0.003);
>>>         filter.setUpper(5);
>>>         filter.setReplaceValue((short) 5);
>>>
>>>         /* seed points */
>>>         seedList.clear();
>>>         seedList.push_back(100);
>>>         seedList.push_back(16);
>>>         seedList.push_back(46);
>>>
>>>
>>>         Image output = filter.execute(input);
>>>         writer.execute(output);
>>>
>>>     }
>>>
>>> Do you know how to make it work?
>>>
>>> Thank you !
>>>
>>>
>>> 2013/4/26 Samuel Pichardo <sammeuly at gmail.com>
>>>
>>>> Hi
>>>>
>>>> In Python, you could use rather numpy io function
>>>> http://docs.scipy.org/doc/numpy/reference/generated/numpy.fromfile.html
>>>> and convert the arrays to simpleITK with
>>>> *SimpleITK*.*GetImageFromArray*<http://www.nullege.com/codes/search/SimpleITK.GetImageFromArray>
>>>>
>>>> Regards
>>>>
>>>> Sam
>>>>
>>>>
>>>> On 2013-04-26, at 4:59 AM, Thibault Varacca <thibault.varacca at gmail.com>
>>>> wrote:
>>>>
>>>> Dear all,
>>>> I'm looking to load and read raw images with simpleITK but I didn't
>>>> find any RawReader().
>>>> How can i do this?
>>>> Thanks !
>>>>
>>>> --
>>>> Thibault Varacca
>>>> EFREI Promo 2014
>>>> 06 60 53 11 35
>>>>  _____________________________________
>>>> Powered by www.kitware.com
>>>>
>>>> Visit other Kitware open-source projects at
>>>> http://www.kitware.com/opensource/opensource.html
>>>>
>>>> Kitware offers ITK Training Courses, for more information visit:
>>>> http://www.kitware.com/products/protraining.php
>>>>
>>>> Please keep messages on-topic and check the ITK FAQ at:
>>>> http://www.itk.org/Wiki/ITK_FAQ
>>>>
>>>> Follow this link to subscribe/unsubscribe:
>>>> http://www.itk.org/mailman/listinfo/insight-users
>>>>
>>>>
>>>>
>>>
>>>
>>> --
>>> Thibault Varacca
>>> EFREI Promo 2014
>>> 06 60 53 11 35
>>>  _____________________________________
>>> Powered by www.kitware.com
>>>
>>> Visit other Kitware open-source projects at
>>> http://www.kitware.com/opensource/opensource.html
>>>
>>> Kitware offers ITK Training Courses, for more information visit:
>>> http://www.kitware.com/products/protraining.php
>>>
>>> Please keep messages on-topic and check the ITK FAQ at:
>>> http://www.itk.org/Wiki/ITK_FAQ
>>>
>>> Follow this link to subscribe/unsubscribe:
>>> http://www.itk.org/mailman/listinfo/insight-users
>>>
>>>
>>>
>>
>>
>> --
>> Thibault Varacca
>> EFREI Promo 2014
>> 06 60 53 11 35
>>
>
>
>
> --
> Thibault Varacca
> EFREI Promo 2014
> 06 60 53 11 35
>
>
>


-- 
Thibault Varacca
EFREI Promo 2014
06 60 53 11 35
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20130430/cafb19a5/attachment.htm>


More information about the Insight-users mailing list