image processing, (thresholding images to obtain image with the required gray values )

1 次查看(过去 30 天)
Hello every one,
I know how to display gray images with specific limits, for an example, if I want to diplay an image (I) with values from 0-150; I only do the following:
imshow (I, [0 150]);
However, now I am trying to save this image at 'A' , but I don't know how can I do that?
I tried the following
A= I<150 ;
but the answer was binary (i.e., black and white, zeros and ones) !! and I want to save gray image as what was obtained from (imshow(I, [0 150])) command in variable 'A'.

回答(1 个)

Image Analyst
Image Analyst 2022-5-30
Try this:
A150 = uint8(double(A) * 255 / 150);
imwrite(A150, 'A150.png');
This will scale A from 0 to 433.5 but then the uint8() function clips it to 255, so that what was 150 now shows up as 255.
You can also use imadjust.
  7 个评论
DGM
DGM 2022-5-31
If you're trying to automatically normalize based on the image extrema, bear in mind that using imadjust() with the implicit input range syntax will be problematic unless your image is scaled correctly for its class.
Anas Saleh
Anas Saleh 2022-5-31
Thank you all,
I will try to use these methods, and if I face any problems I will tell you.
Many thanks

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Image Processing Toolbox 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by