Hi,
From a polygon selection I'd like to copy a donut shaped ROI (15 pixels either side of selection) paste this into a new image and then overlay the same polygon selection onto the pasted image. The polygon is not always centred. The first macro shows the problem with this (the final polygon does not align). I worked out how to fix this by cropping the image first but the 'setKeyDown("alt");' command does not function correctly in the second macro. I can't find a workaround is this a bug or am I missing something? //Macro 1: newImage("Untitled", "RGB White", 1250, 1250, 1); makePolygon(264,96,308,104,348,130,392,138,436,144,490,146,514,134,568,118,600,104,656,108,696,124,716,172,722,244,700,314,646,374,584,410,510,412,418,412,356,396,316,374,258,348,226,312,212,266,190,224,184,166,216,120); width = getWidth(); height = getHeight(); getSelectionCoordinates(x,y); { makeSelection("polygon", x, y); run("Enlarge...", "enlarge=15"); setKeyDown("alt"); makeSelection("polygon", x, y); run("Enlarge...", "enlarge-15"); run("Copy"); close(); newImage("PatchPlot", "RGB Black", width, height, 1); run("Paste"); run("Make Binary"); run("Median...", "radius=2"); } //make polyline makeSelection("polygon", x, y); //..................................................................... ///Macro 2: newImage("Untitled", "RGB White", 1250, 1250, 1); makePolygon(264,96,308,104,348,130,392,138,436,144,490,146,514,134,568,118,600,104,656,108,696,124,716,172,722,244,700,314,646,374,584,410,510,412,418,412,356,396,316,374,258,348,226,312,212,266,190,224,184,166,216,120); width = getWidth(); height = getHeight(); getSelectionCoordinates(x,y); { makeSelection("polygon", x, y); run("Enlarge...", "enlarge=15"); setKeyDown("alt"); makeSelection("polygon", x, y); run("Enlarge...", "enlarge-15"); run("Copy"); close(); newImage("PatchPlot", "RGB Black", width, height, 1); run("Paste"); run("Make Binary"); run("Median...", "radius=2"); } //make polyline makeSelection("polygon", x, y); -- Dr Richard Mort MRC Human Genetics Unit Western General Hospital Crewe Road Edinburgh EH4 2XU, UK. Phone: +44 (0)131 332 2471 x 3205 Fax: +44 (0)131 467 8456 |
Hi Richard,
when copying part of an image, only the size is stored in the clipboard, not its position. So for pasting into a specific area, the target image should have a selection that matches the selection where the clipboard comes from. As long as the source image is open, you can easily transfer the selection by "restore selection", see the sample macro below. Otherwise, you can use the roi manager. Michael ________________________________________________________________ ///Macro 3: newImage("Untitled", "RGB White", 1250, 1250, 1); id = getImageID(); makePolygon (264,96,308,104,348,130,392,138,436,144,490,146,514,134,568,118,600,104, 656,108,696,124,716,172,722,244,700,314,646,374,584,410,510,412,418,412, 356,396,316,374,258,348,226,312,212,266,190,224,184,166,216,120); width = getWidth(); height = getHeight(); getSelectionCoordinates(x,y); { makeSelection("polygon", x, y); run("Enlarge...", "enlarge=15"); setKeyDown("alt"); makeSelection("polygon", x, y); run("Enlarge...", "enlarge-15"); run("Copy"); newImage("PatchPlot", "RGB Black", width, height, 1); run("Restore Selection"); run("Paste"); run("Make Binary"); run("Median...", "radius=2"); } //make polyline makeSelection("polygon", x, y); selectImage(id); close(); ________________________________________________________________ On 21 Nov 2008, at 11:35, Richard Mort wrote: > Hi, > From a polygon selection I'd like to copy a donut shaped ROI (15 > pixels either side of selection) paste this into a new image and > then overlay the same polygon selection onto the pasted image. The > polygon is not always centred. The first macro shows the problem > with this (the final polygon does not align). I worked out how to > fix this by cropping the image first but the 'setKeyDown("alt");' > command does not function correctly in the second macro. I can't > find a workaround is this a bug or am I missing something? |
Free forum by Nabble | Edit this page |