Extract image from imtool into variable.

I've found that I can change the display range of a Dicom image using something alone the lines of imtool(MB, [1850 25725]); (or the same with imshow). Instead of displaying it, I want to use the resulting image in my code for further calculation. Is there another function I can use instead that doesn't display the image, or can I extract it automatically from imtool?

 Réponse acceptée

Image Analyst
Image Analyst le 17 Avr 2013

0 votes

You have MB. Somehow you got it, like from dicomread() or somewhere, so you don't need to "extract it" from imtool - you already have it. So just start working with it. You don't need to display it with imshow(), image(), imagesc(), imtool() or anything else. You can work with it just like any other numerical array.

6 commentaires

Kenny Williams
Kenny Williams le 17 Avr 2013
Modifié(e) : Kenny Williams le 17 Avr 2013
I'm sorry, I wasn't clear. I'm changing the display range, so now the noise in the original image is gone. I want to change the range so that the image without the noise is saved over MB.
Image Analyst
Image Analyst le 17 Avr 2013
You're still not being clear. Changing the display range does not remove noise though it may make is less visible. If you know the display range and want to map your image into that you can try imadjust(). Or mat2gray() or simple scaling, or setting values in a certain range to zero, or whatever. Not sure what you want to do until you give an example with, say, a small 5 by 5 sample image so we can see what values you want to set to what.
Kenny Williams
Kenny Williams le 17 Avr 2013
Modifié(e) : Kenny Williams le 17 Avr 2013
Say I have the code:
MB = rand(5);
imshow(MB); figure; imshow(MB, [10 100]);
The two images displayed look different. I want to save the second image so that when I call imshow() without the display range parameters, it will show the second image.
I've tried MB(MB <= 1850) = 0; MB(MB >= 25725) = 2^16; (for my image) but it doesn't look the same at all.
EDIT: Removed images. Not sure if I have permission to post them, so I probably shouldn't.
Did you try any of my other suggestions, or just that one? For example, did you try imadjust(), or scaling, like this:
actualMin = double(min(min(imgOriginal)));
actualMax = double(max(max(imgOriginal)));
slope = (desiredMax - desiredMin) / (double(actualMax) - double(actualMin));
scaledImage = slope * (double(imgOriginal) - actualMin) + desiredMin;
You shouldn't just quit after trying one thing.
Kenny Williams
Kenny Williams le 17 Avr 2013
It's not that I was quitting. I found a function that displayed a desirable image, I was just curious if it allowed the image to be saved instead of displayed. I briefly looked into imadjust (before I found imtool) before, but it only takes values between 0 and 1 so in searching for a function that took the min and max values directly I found imtool. However, having taken another look at imadjust, I've realized I can do basically imadjust(MB, [128 / 1850 25725 / 2^16]) and achieve what I want. So, thank you for directing me to that function again.
Image Analyst
Image Analyst le 17 Avr 2013
Modifié(e) : Image Analyst le 17 Avr 2013
You're welcome.

Connectez-vous pour commenter.

Plus de réponses (1)

Mary
Mary le 17 Fév 2014

0 votes

hi I want to measure the length of small objects on an image by using a imtool but i like to save the measurement which i got from imtool any one can help on that please?? Many thanks

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by