Change the image contrast using imtool
1 次查看(过去 30 天)
显示 更早的评论
Hey!
I need a little push about one simple problem, and I want to automate one thing.
For example: Img is a grayscale image and I need to put min and max values as [0 160], then I want to 'Adjust Data', and save an output image.
imtool(Img,[0 160])
% here I need line which is for adjusting changed data
ImgOutput=getimage(imgca);
Thank you in advance!
2 个评论
Jürgen
2012-8-20
Hi,
maybe I am mistaken, but based on your information I do not understand what you want to do? Do you to do? " I want to 'Adjust Data', and save an output image." what do you mean by adjust?
saving an image can be done: saveas(gcf,'YourFig.jpg')
Ryan
2012-8-20
adjustedImage = imadjust(inputImage,[low_in; high_in], [low_out; high_out]);
回答(1 个)
Image Analyst
2012-8-20
编辑:Image Analyst
2012-8-20
You can use intlut()
clc; % Clear command window.
workspace; % Make sure the workspace panel is showing.
% Read in sample image.
grayImage = imread('moon.tif');
subplot(1, 2, 1);
imshow(grayImage);
colorbar;
% Create a look up table to map [min, max] to [0 160]
minGL = min(grayImage(:));
maxGL = max(grayImage(:));
lut = zeros(1, 256, 'uint8');
lut(minGL+1:maxGL+1) = linspace(0, 160, maxGL-minGL+1);
lut(maxGL+2:end) = 160;
% Apply the look up table to create a new image
% which will be in the range 0-160.
image160 = intlut(grayImage, lut);
% Display image.
subplot(1, 2, 2);
imshow(image160);
colorbar;
% Enlarge figure to full screen.
set(gcf, 'units','normalized','outerposition',[0 0 1 1]);
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!