Adjusting CData to match CLim for grayscale Image
Mostrar comentarios más antiguos
I have a grayscale image in a figure displayed through imshow. I adjust the axes CLim limits [a b] to improve it's contrast to desired levels. How can I adjust the image matrix (CData) to match the image displayed by my CLim limits? I've tried imadjust function i.e. Image2=imadjust(Image1,[a b],[]) , but the resultant Image2 contrast doesn't look like the one displayed by CLim limits [a b].
Respuesta aceptada
Más respuestas (1)
Image Analyst
el 21 de Abr. de 2016
0 votos
What are you trying to do? If you want to stretch contrast, you can pass in the values you want for black and white into imshow(). Or else call caxis(). I don't understand why you would ask what you asked.
4 comentarios
John
el 21 de Abr. de 2016
Image Analyst
el 22 de Abr. de 2016
Yeah it works but it's somewhat inefficient because it has to compute two intermediate images. Anyway, there's a function for doing that normalization - it's called mat2gray().
But John, I think you might have bee a little too quick to discard my answer. caxis just does a look up table modification so it's really fast and uses no extra memory. I think you just didn't know what I was suggesting so I give you an example:
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
clear; % Erase all existing variables. Or clearvars if you want.
workspace; % Make sure the workspace panel is showing.
format compact;
fontSize = 20;
format short g;
% Read in low contrast image.
imshow('pout.tif');
colormap(gray(256));
colorbar;
% Set up figure properties:
% Enlarge figure to full screen.
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0 0 1 1]);
% Get rid of tool bar and pulldown menus that are along top of figure.
set(gcf, 'Toolbar', 'none', 'Menu', 'none');
% Give a name to the title bar.
set(gcf, 'Name', 'Demo by ImageAnalyst', 'NumberTitle', 'Off')
promptMessage = sprintf('Click continue to adjust caxis');
titleBarCaption = 'Continue?';
buttonText = questdlg(promptMessage, titleBarCaption, 'Continue', 'Quit', 'Continue');
if strcmpi(buttonText, 'Quit')
return;
end
for k = 1 : 5 : 200
caxis([k, 255]);
pause(0.1);
end
promptMessage = sprintf('Click continue to adjust caxis');
titleBarCaption = 'Continue?';
buttonText = questdlg(promptMessage, titleBarCaption, 'Continue', 'Quit', 'Continue');
if strcmpi(buttonText, 'Quit')
return;
end
colormap(gray(256));
for k = 254 : -5 : 65
caxis([0, k]);
pause(0.1);
end
promptMessage = sprintf('Click continue to adjust caxis');
titleBarCaption = 'Continue?';
buttonText = questdlg(promptMessage, titleBarCaption, 'Continue', 'Quit', 'Continue');
if strcmpi(buttonText, 'Quit')
return;
end
colormap(gray(256));
for k = 1 : 5 : 127
caxis([k, 255-k]);
pause(0.2);
end
Walter Roberson
el 22 de Abr. de 2016
The intermediate images probably would not be too large.
John
el 22 de Abr. de 2016
Categorías
Más información sobre Display 2-D Images en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!