Custom ROI by program

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Custom ROI by program

radone
Hello,
I know how to make Rectangle ROI using e.g.

                IJ.open("c:/download/MRFdemo/images/mdb297.jpg");
                ImagePlus img = IJ.getImage();
                img.setRoi(new Roi(0, 0, 50, 50));


How can I make a custom ROI? I am trying to do that using:

                IJ.open("c:/download/MRFdemo/images/mdb297.jpg");
                ImagePlus img = IJ.getImage();

                IJ.open("c:/download/MRFdemo/images/mdb297.jpg");
                ImagePlus mask = IJ.getImage();

                byte[] maskD = (byte[]) mask.getProcessor().getPixels();
                for (int j = 0; j < 10; j++) {
                        for (int i = 0; i < 100; i++) {
                                maskD[j*img.getWidth() + 0 + i * 3] = -1;
                                maskD[j*img.getWidth() + 1 + i * 3] = -1;
                                maskD[j*img.getWidth() + 2 + i * 3] = -1;
                        }
                }



Unfortunately, it seem that it does not work - show() command does not show anything and img.getRoi() return NULL.

Thanks for any help.