From: jabgars kohli on 9 Aug 2010 16:25 Hello Chritopher I was trying the code that you posted with the same image, but I'm getting an error saying "Error using ==> rgb2gray>parse_inputs at 82 MAP must be a m x 3 array. Error in ==> rgb2gray at 35 X = parse_inputs(varargin{:});" I have a similar image that i needs to threshold but even I'm get the same error. Do you have any clue about this ? > Hi Valentin, > > I haven't really tried but it seems that the key phrase here is to 'try a combination of thresholds'. ImageAnalyst is correct in saying that the expected results provided are greyscale images. These can not be obtained from pure, single threshold procedures, which produce a logical mask (i.e either 1 or 0 for each pixel). > > Therefore, I think what you need to do is almost quantise - that is, use a number of thresholds. For instance, say: > > <pre class="code"> > % read image and ensure it is greyscale for thresholding > inImage = imread('cerveau.jpg'); > greyImage = rgb2gray(inImage); > > % define 'white' to be any pixel greater than thresh1 > thresh1 = 200; > whiteLayer = greyImage > thresh1; > > % define 'lightGrey' to be any pixel greater than thresh2 but less than or equal to > % thresh1 > thresh2 = 125; > lightgreyLayer = greyImage > thresh2 & greyImage <= thresh1; > > % etc... > </pre> > > Each layer is logical and each pixel within each layer is either 1 (true) or 0 (false). Set each layer to be a given value of grey... > > <pre class="code"> > layer1 = whiteLayer*200; > layer2 = lightGreyLayer*125; > > % etc... > </pre> > > Now simply superimpose each layer by adding them. Remember each pixel should only belong to one layer... > > <pre class="code"> > newGreyscale = layer1 + layer2 + ... > </pre> > > Still.. it would require many layers to achieve the results expected.. but this is the sort of thing that is expected I think. > > The other thing is that the image of the expected result is not one expected result, it is instead BOTH of the expected results. I don't believe any single common thresholding applied to the original can produce that. > Instead I think that it is a comparative image showing the results of both operations. Remember the question asks you to use 'thresholds both above the white peak and below it'. > This is confusing and I'm not sure what they mean by 'white peak' so.. these are some things that may aid your solution. > > Hope that helps, > > Chris
|
Pages: 1 Prev: High Frequency Digital I/O Next: Contouring directional data in polar co-ords |