Change the image contrast using imtool

1 回表示 (過去 30 日間)
Marko Baros
Marko Baros 2012 年 8 月 20 日
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
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
Ryan 2012 年 8 月 20 日
I am not sure what you are looking to do exactly, but perhaps imadjust would help?
adjustedImage = imadjust(inputImage,[low_in; high_in], [low_out; high_out]);

サインインしてコメントする。

回答 (1 件)

Image Analyst
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]);

カテゴリ

Help Center および File ExchangeExplore and Edit Images with Image Viewer App についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by