Hi
i'm new in the imageJ, and i have to make a plugin in java which: if you have a polygon slection, it makes a mask which is the same size as the picture and make the selection black and the not selected is white... so i have made: 1.: open an image 1/b.: make a polygon slection 2.: make a new mask 3.: triing to draw a new polygon, but gut a null pointer exeption. (Graphics g=null; g.drawPolygon(p.xpoints, p.ypoints, p.npoints);) please help me how can i make polygon on the mask? |
Hi David,
if you write > Graphics g=null; > g.drawPolygon(p.xpoints, p.ypoints, p.npoints); must get a NullPointerException because g = null, so you can't call a method of the Object g. Why not simply use IJ.run("Create Mask"); It will create an ImagePlus with the mask. If you don't want an ImagePlus but only an ImageProcessor, type lowercase L in ImageJ, search for 'create mask" select 'show full information' and type 'Source'. YOu can then have a look at the sourcecode, in this case ij.plugin.Selection.createMask. There you can steal the code for how to create an ImageProcessor with the mask, basically Roi roi = imp.getRoi(); ImageProcessor ip = new ByteProcessor(imp.getWidth(), imp.getHeight()); ip.setRoi(roi); ip.setValue(255); ip.fill(ip.getMask()); Michael ________________________________________________________________ On Nov 28, 2012, at 16:33, greendoki wrote: > Hi > > i'm new in the imageJ, and i have to make a plugin in java which: if you > have a polygon slection, it makes a mask which is the same size as the > picture and make the selection black and the not selected is white... > > so i have made: > 1.: open an image > 1/b.: make a polygon slection > 2.: make a new mask > 3.: triing to draw a new polygon, but gut a null pointer exeption. > (Graphics g=null; > g.drawPolygon(p.xpoints, p.ypoints, p.npoints);) > > please help me how can i make polygon on the mask? > -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
2012.11.29. 10:33 keltezéssel, Michael
Schmid-3 [via ImageJ] írta:
Hi David,Can u pls tell me how can i save this mask? Thanks for your answers! -- Üdvözlettel: Lakatos Dávid [hidden email] |
Free forum by Nabble | Edit this page |