Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: problem with imreconstruct
Date: Sat, 26 Feb 2011 18:20:22 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 91
Message-ID: <ikbg96$adq$1@fred.mathworks.com>
References: <ijpaam$9ep$1@fred.mathworks.com> <9dd6a81c-bf21-40dc-a7b8-9844bc58fa4c@z3g2000prz.googlegroups.com> <021cd4f9-eea5-4dec-ba2f-73fdb50eb490@y36g2000pra.googlegroups.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: www-02-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1298744422 10682 172.30.248.47 (26 Feb 2011 18:20:22 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sat, 26 Feb 2011 18:20:22 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 2671557
Xref: news.mathworks.com comp.soft-sys.matlab:712585

Thank you very much ImageAnalyst for your time. I wrote my codes using the cameraman image and again I am getting the same error. Could you please test the following codes:

 im=imread('cameraman.tif');
  m3=zeros(256,256);
  
  m3(im>=1.6753e+004)=1;
  logicalm3=logical(m3);

M=zeros(256, 256);
M(141:151,88:108)=1;

 Ieroded=imerode(M,strel('disk',1));
    Iskeleton=bwmorph(Ieroded,'skel',Inf);
    mymarker=M & Iskeleton;
    
 I3= imreconstruct(mymarker, logicalm3);

The error is again ; 
??? Error using ==> imreconstructmex
MARKER pixels must be <= MASK pixels.

Error in ==> imreconstruct at 71
  im = imreconstructmex(marker,mask);

What must I do to get rid of this problem ?

ImageAnalyst <imageanalyst@mailinator.com> wrote in message <021cd4f9-eea5-4dec-ba2f-73fdb50eb490@y36g2000pra.googlegroups.com>...
> Ferrari P. :
> OK, I spent a couple of minutes and did the demo for you.  I don't see
> any problem with it.  How does this differ from your code?  I can't
> help as much if you don't provide your code, your image, or any more
> information:
> 
> % IMPORTANT: The newsreader may break long lines into multiple lines.
> % Be sure to join any long lines that got split into multiple single
> lines.
> % These can be found by the red lines on the left side of your
> % text editor, which indicate syntax errors, or else just run the
> % code and it will stop at the split lines with an error.
> % function test1
> clc;
> clear;  % Erase all existing variables.
> workspace;  % Make sure the workspace panel is showing.
> fontSize = 20;
> 
> % Change the current folder to the folder of this m-file.
> if(~isdeployed)
> 	cd(fileparts(which(mfilename)));
> end
> 
> % Check that user has the Image Processing Toolbox installed.
> hasIPT = license('test', 'image_toolbox');
> if ~hasIPT
> 	% User does not have the toolbox installed.
> 	message = sprintf('Sorry, but you do not seem to have the Image
> Processing Toolbox.\nDo you want to try to continue anyway?');
> 	reply = questdlg(message, 'Toolbox missing', 'Yes', 'No', 'Yes');
> 	if strcmpi(reply, 'No')
> 		% User said No, so exit.
> 		return;
> 	end
> end
> 
> grayImage = peaks(256);
> % Display the original image.
> subplot(2, 2, 1);
> imshow(grayImage, []);
> title('Image for deriving a binary image', 'FontSize', fontSize);
> % Enlarge figure to full screen.
> set(gcf, 'Position', get(0,'Screensize'));
> 
> % Get a binary image.
> binaryImage = grayImage > 3;
> % Display the image.
> subplot(2, 2, 2);
> imshow(binaryImage, []);
> title('The Starting Binary Image', 'FontSize', fontSize);
> 
> % Erode it to form a marker image.
> % Erode it wnough to have only 2 blobs instead of 3
> markerImage = imerode(binaryImage, ones(15));
> % Display the image.
> subplot(2, 2, 3);
> imshow(markerImage, []);
> title('Marker Image = Eroded Binary Image', 'FontSize', fontSize);
> 
> reconst = imreconstruct(markerImage, binaryImage);
> % Display the reconstructed image.
> subplot(2, 2, 4);
> imshow(reconst, []);
> title('Final Reconstructed Image', 'FontSize', fontSize);