Hi
I am writing a macro to analyzing an Image. The analysis results (text and plot screen captures) are written to 4 new images. To produce the final report I convert these images to stack. At this point I loose all my screen captures and text remain on the images. The following is the code I use for screen capturing and pasting to the new image: //(5) Select the plot for copying selectWindow(ImageTitle+PlaneType+" Profile"); SelImgWdth = getWidth(); SelImgHght = getHeight(); //(6) Copy it run("Copy"); //********************************************************************** // Create new Image numSlices = 1; npadpixels =10; FontName = "Bookman Old Style"; FontSize = 26; FontStyle = "bold"; TxtJustification = "center"; NewImageName = PlaneType + "AnalysesResult"; TypeAndFill = "RGB white"; newImage(NewImageName, TypeAndFill, Width, Height, numSlices); // Write its title //=============================================== setFont(FontName, FontSize, FontStyle); setColor(0, 0, 0); //This Black setJustification(TxtJustification); x = (Width / 2); y = FontSize + npadpixels; drawString(NewImageTitle, x, y); // Draw underline //========================= x = 20; y = y+ npadpixels; setLineWidth(3); drawLine(x, y, Width-x, y); y = y + (npadpixels / 2); drawLine(x, y, Width - x, y); // Skip two lines //=================================== //y = SkipnLines(y, FontSize, npadpixels, 0); y = y + 2 * npadpixels; // Paste the plot to the new image ImageToPaste = ImageTitle + PlaneType + " Profile"; xCoordinate = npadpixels; yCoordinate = y; PasteAtxy(ImageToPaste,xCoordinate, yCoordinate); //==== Start Add picture at given (x,y) function ======================= function PasteAtxy(ImageToPaste,xCoordinate, yCoordinate){ // Paste the plot to the new image StrCommand = "image=[" + ImageToPaste + "] x="; StrCommand = StrCommand + xCoordinate + " y="; StrCommand = StrCommand + yCoordinate +" opacity=100"; run("Add Image...", StrCommand); } //==== End Add picture at given (x,y) function ========================= after image creation after converting to stack What am I doing wrong? Why do I loose the screen capture? Thanks in advance for the help and attention Mat Al-Tamimi mtamimi@netzero.net |
Hi Mat,
you use the "Add Image..." command; it creates an overlay, so the plot that you add is not part of the image. You will see this if you move the cursor over the image; the status line of the ImageJ toolbar will show the value of the background pixels. To avoid this, you can use 'Flatten', it will create a new image with the overlay; then discard the original. As an alternative, copy the plot (while it is in the foreground), create a rectangular selection with the width&height of the plot at the desired position, and use the "Paste" command. Michael ________________________________________________________________ On Jul 19, 2015, at 00:33, mtamimi wrote: > Hi > > I am writing a macro to analyzing an Image. The analysis results (text and > plot screen captures) are written to 4 new images. To produce the final > report I convert these images to stack. At this point I loose all my screen > captures and text remain on the images. > The following is the code I use for screen capturing and pasting to the new > image: > > > //(5) Select the plot for copying > selectWindow(ImageTitle+PlaneType+" Profile"); > SelImgWdth = getWidth(); > SelImgHght = getHeight(); > > //(6) Copy it > run("Copy"); > > //********************************************************************** > // Create new Image > numSlices = 1; > npadpixels =10; > > FontName = "Bookman Old Style"; > FontSize = 26; > FontStyle = "bold"; > TxtJustification = "center"; > > NewImageName = PlaneType + "AnalysesResult"; > TypeAndFill = "RGB white"; > > newImage(NewImageName, TypeAndFill, Width, Height, numSlices); > > // Write its title > //=============================================== > setFont(FontName, FontSize, FontStyle); > setColor(0, 0, 0); //This Black > setJustification(TxtJustification); > x = (Width / 2); > y = FontSize + npadpixels; > drawString(NewImageTitle, x, y); > > // Draw underline > //========================= > x = 20; > y = y+ npadpixels; > setLineWidth(3); > drawLine(x, y, Width-x, y); > y = y + (npadpixels / 2); > drawLine(x, y, Width - x, y); > > // Skip two lines > //=================================== > //y = SkipnLines(y, FontSize, npadpixels, 0); > y = y + 2 * npadpixels; > > // Paste the plot to the new image > ImageToPaste = ImageTitle + PlaneType + " Profile"; > xCoordinate = npadpixels; > yCoordinate = y; > PasteAtxy(ImageToPaste,xCoordinate, yCoordinate); > > //==== Start Add picture at given (x,y) function ======================= > function PasteAtxy(ImageToPaste,xCoordinate, yCoordinate){ > > // Paste the plot to the new image > StrCommand = "image=[" + ImageToPaste + "] x="; > StrCommand = StrCommand + xCoordinate + " y="; > StrCommand = StrCommand + yCoordinate +" opacity=100"; > run("Add Image...", StrCommand); > } > > //==== End Add picture at given (x,y) function ========================= > > after image creation > <http://imagej.1557.x6.nabble.com/file/n5013633/01.png> > after converting to stack > <http://imagej.1557.x6.nabble.com/file/n5013633/02.png> > > > What am I doing wrong? Why do I loose the screen capture? > > Thanks in advance for the help and attention > Mat Al-Tamimi -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Free forum by Nabble | Edit this page |