From: Valentin Rabanelly on 30 Jun 2010 19:13 Hey everyone! I'm trying to treat this image with Matlab : http://img710.imageshack.us/img710/3743/cerveau.jpg (original file for those who will try it in Matlab : http://www.mediafire.com/file/oj2wxtd2mnv/brains.pgm) Here are the instructions I have: The image shows a nuclear magnetic resonance of the brain. In this picture, the different tissue types have different levels of gray. Identify the regions of white matter in the histogram of the image. Use a combination of thresholds above and below the peak of white matter and simple arithmetic to create your own segmentation. Result expected: http://img808.imageshack.us/img808/2245/cerveauresultat.jpg Here is what I tried so far: "pictureAfterThreshold = brainPicture > 180;" Result: http://img338.imageshack.us/img338/6075/cerveauobtenu1.jpg This is very radical in the sense that it retains only the pixels whose value is between 180 and 255 in the original image. I liked the result a bit more nuanced, with a transition zone between the black and the white area in the result which is less steep. I also tested this: "grayLevels graythresh = (brainPicture); brainPictureBW im2bw = (brainPicture, grayLevels);" Result: http://img10.imageshack.us/img10/1740/cerveauobtenu2.png The result is similar to the one presented above, but in reality, a little further from the expected result because it filters too much the original image. Well, from here and with the instructions I have, I don't know which way to follow to achieve the expected result ... Could you please help me? Thank you very much!
From: ImageAnalyst on 30 Jun 2010 20:12 You're thresholding - getting a binary image - but the result you're supposed to get is not a binary image, so you need to determine the thresholds that will give you a mask image, then multiply the mask image by the original image. Then it looks like they stretched the contrast.
From: Christopher on 1 Jul 2010 00:25 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
From: Valentin Rabanelly on 1 Jul 2010 11:15 Hi! Thanks for your help, both of you! With your advices, I used this function over my original picture : "function picOut = applyMask(picture,threshold) // Get Logical Mask mask = picture > threshold; // Adjust the gray levels to get the clearest values possible // (the picture was staying gray if I was just applying the mask) picture = picture + (255-threshold); // apply mask over the picture picture(mask)=0; // Invert White / Black to go to the expected result picOut = 255-picture;" The result is here : http://img228.imageshack.us/img228/9454/resultbrain1.jpg I already find it a lot better than before, but I think there is still a problem in the dark values, because the center of the dark zones is clearer than the borders... And in the original image, it wasn't like this... I guess the inversion I did with "picOut = 255-picture" does this, but I don't see an other way to do it... Any idea please? Christopher, I tried your solution, with the following code : "function picOut = applicateThresholds(picture) tresh1 = 200; tresh2 = 125; tresh3 = 55; whiteLayer = picture > tresh1; lightGrayLayer = picture > tresh2 & picture <= tresh1; darkGrayLayer = picture > tresh3 & picture <= tresh2; blackLayer = picture <= tresh3; layer1 = whiteLayer * 255; layer2 = lightGrayLayer * 200; layer3 = darkGrayLayer * 125; layer4 = blackLayer * 55; allLayers = layer1 + layer2 + layer3 + layer4; picOut = uint8(allLayers);" But the result I got isn't really convincing... Did I do something wrong? The result : http://img804.imageshack.us/img804/2668/resultbrain2.jpg Thanks!!
From: ImageAnalyst on 1 Jul 2010 15:42 From your "expected results" I can't see where a threshold is involved. Sure they tell you to, but it looks like they simply just did a contrast stretch, either a global one for the whole image, or a locally adaptive one, like for example adapthisteq(). They definitely did a contrast stretch, so whether or not they did a masking beforehand (by choosing thresholds) is immaterial - at least I can't really see any masking in the image. So their expected image result doesn't make much sense as far as their instructions go. However, you could produce 2 or 3 masks representing the pixels with 2 or 3 different kinds of brain material if you had the 2 or 3 low & high threshold pairs. These images (one for each tissue type) are not shown.
|
Next
|
Last
Pages: 1 2 Prev: spectrogram Next: Using Rapid Accelerator from command line function "sim" |