Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Printing an image to scale
Date: Fri, 4 Apr 2008 09:31:02 +0000 (UTC)
Organization: Finnish Environment Institute
Lines: 66
Message-ID: <ft4sgm$knm$1@fred.mathworks.com>
References: <ft1nph$5rv$1@fred.mathworks.com> <ft3riu$98e$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1207301462 21238 172.30.248.37 (4 Apr 2008 09:31:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Fri, 4 Apr 2008 09:31:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 953264
Xref: news.mathworks.com comp.soft-sys.matlab:461027



"Dan Haeg" <haegd@msoe.edu> wrote in message
<ft3riu$98e$1@fred.mathworks.com>...
> "Joshua Fialkoff" <fialkj@rpi.edu> wrote in message
> <ft1nph$5rv$1@fred.mathworks.com>...
> > Hi all,
> > Say we import an image into MATLAB.  I can print/export that
> > image at the same resolution and using the same file type
> > and have the same image (i.e., it will match the dimensions
> > of the original).  Similarly, I can perform some operations
> > directly on the matrix that represents the image and, again,
> > export and get a similarly sized image.  The problem is
> > this.  I would like to show the image using imshow and then
> > overlay some shapes (e.g., bounding boxes, etc...) and then
> > export the image such that it is similarly sized as the
> > original.  I can't seem to figure out how to accomplish
> > this.  If it helps I'm only working with B&W images, but a
> > more generic solution is preferable.  Thanks in advance for
> > you help.
> > 
> > - Josh
> 
> I have the same problem. My image is 5939 by 4639 pixels so
> it is way too big for my screen when not zoomed. I read the
> image and display it. Then I plot some non-trivial lines on
> top of the image. Now I want to print the combined image
> with lines to the same size file as the original ie 5939 by
> 4639. The image is true color.
> 
> Here is my thread:
>
http://www.mathworks.com/matlabcentral/newsreader/view_thread/166433#423529
> 
> If anyone can solve both our problems that would be great,
> thanks.
> Dan

Hi,

One method is described  here:
http://www.mathworks.com/support/solutions/data/1-16WME.html?solution=1-16WME

However, the "background" image may not have exactly same
colors as the original when exported trough print().

load clown
figH = figure;
axH = axes('units','normalized','position',[0 0 1 1]);
imH  = imshow(X,map,'parent',axH);
colormap(map);
hold on, patch([ 50 100 50]',[50 100 100]','r','LineWidth',3)
text(150,20,'Clown','color',[0 0
0],'fontweight','bold','fontsize',14)
axis off
    
figSize = size(X);
defRes = 100;
paperPos = fliplr(figSize/defRes);
set(figH,'PaperUnits','inches','PaperPosition',[0 0 paperPos]);
% "save" figure with annotations
print('-dpng','new.png',['-r',num2str(defRes)])


HTH, 

M