From: David on 3 Feb 2010 18:45 Hello, I have a question regarding the code given below. If you run the code, it'll bring up an image of a random number matrix. If you draw an ellipse on this image and double-click on it, you'll get a 3-plot figure with the first and second plots identical, and the third plot completely black (all zeros). Now, run the code again, but maximize the figure window so that it fills the screen, then draw an ellipse and double-click. Here, the third image of the resulting figure is not totally black. Why? I understand that imellipse uses rasterization to calculate the position of the indices, and that the createMask function probably determines whether a pixel is a 1 or a 0 based on rounding the fractions of pixels enclosed along the perimeter of the ellipse. However, since I'm drawing (or at least I think I'm drawing) an identical ellipse for the second mask, shouldn't the rounding calculations be identical as well? Perhaps something else is going on that I don't see? Thanks, any help would be appreciated, ~David function ellipsetest() M = rand(100,300); figure; h_im = imshow(M,'Border','tight'); impixelinfo; p = imellipse; indices = wait(p); Winsize = get(gcf,'outerposition'); Roi1 = createMask(p,h_im); Roipos = [min(indices(:,1)),min(indices(:,2)),... max(indices(:,1))-min(indices(:,1)),... max(indices(:,2))-min(indices(:,2))]; close; figure('outerposition',Winsize) h_im = imshow(M,'Border','tight'); r = imellipse(gca,Roipos); Roi2 = createMask(r,h_im); close; subplot(3,1,1),imshow(Roi1),subplot(3,1,2),... imshow(Roi2),subplot(3,1,3),imshow(abs(Roi1-Roi2));
From: Brendan Hannigan on 4 Feb 2010 09:29 Hi David, This isn't exactly an apples to apples comparison. When you call IMSHOW for the second time, it is resizing the figure back to the default size, and figure size does have an affect on how these masks are computed. Perhaps it shouldn't, but that's the reason you are seeing what you are seeing. If you set the 'OuterPosition' property of the second figure AFTER you call IMSHOW for the second time, then you get the expected results. hope this helps! -brendan "David " <dmklein(a)mdanderson.org> wrote in message <hkd1qh$ard$1(a)fred.mathworks.com>... > Hello, > > I have a question regarding the code given below. If you run the code, it'll bring up an image of a random number matrix. If you draw an ellipse on this image and double-click on it, you'll get a 3-plot figure with the first and second plots identical, and the third plot completely black (all zeros). Now, run the code again, but maximize the figure window so that it fills the screen, then draw an ellipse and double-click. Here, the third image of the resulting figure is not totally black. Why? > > I understand that imellipse uses rasterization to calculate the position of the indices, and that the createMask function probably determines whether a pixel is a 1 or a 0 based on rounding the fractions of pixels enclosed along the perimeter of the ellipse. However, since I'm drawing (or at least I think I'm drawing) an identical ellipse for the second mask, shouldn't the rounding calculations be identical as well? Perhaps something else is going on that I don't see? > > Thanks, any help would be appreciated, > ~David > > > function ellipsetest() > > M = rand(100,300); > > figure; > h_im = imshow(M,'Border','tight'); > impixelinfo; > p = imellipse; > indices = wait(p); > Winsize = get(gcf,'outerposition'); > Roi1 = createMask(p,h_im); > Roipos = [min(indices(:,1)),min(indices(:,2)),... > max(indices(:,1))-min(indices(:,1)),... > max(indices(:,2))-min(indices(:,2))]; > close; > > figure('outerposition',Winsize) > h_im = imshow(M,'Border','tight'); > r = imellipse(gca,Roipos); > Roi2 = createMask(r,h_im); > close; > > subplot(3,1,1),imshow(Roi1),subplot(3,1,2),... > imshow(Roi2),subplot(3,1,3),imshow(abs(Roi1-Roi2));
From: David on 4 Feb 2010 12:24 Hi Brendan, Thanks for your reply. Yeah, I figured that the size of the figure mattered as well, and that's why I got Winsize and set the next figure to the same size as as the first figure in the original code. However, when I put a wait after the second imellipse call I found that the imshow function had resized my figure, which I wasn't expecting. So, I just set the second figure using Winsize after I make the imshow call, but before the second imellipse call, and that did the trick. Thanks again, ~David
|
Pages: 1 Prev: FRIENZ / URGENT FOR ALL YOU FASHION FANZ OUT HERE : ) : ) Next: Link to Code Composer Studio? |