adjusts the intensity of the image

8 views (last 30 days)
elena rondina
elena rondina on 29 Jan 2016
Edited: elena rondina on 29 Jan 2016
hi recently i'm studying matlab...i have to adjusts the intensity of the image whit n transformed with different intensity range(>1 and <1)and show their histogram.don't undestand the solution; the code is:
function InspectImadjust(img,tol, n)
img_gray=rgb2gray(img)
if nargin<3
n = 3;
end
if nargin<2
tol = 0.05;
end
figure;
subplot(n+1,2,1);
imshow(img_gray);
title('Immagine a Livelli di grigio');
subplot(n+1,2,2);
imhist(img_gray);
title('istogramma ORIG');
xlabel('l.d.g.');
ylabel('#pixels');
%%CONTRAST STRETCHING
%Sintassi generale: J = imadjust(I,[low_in; high_in],[low_out; high_out],gamma)
step = 1/n;
gammaMin = [];
for i=1:floor(n/2) %%da 1 fino a 1
gammaMin = [1-(i*step)];
end
gammaMin = fliplr(gammaMin);
gammaMax = [];
for i=1:floor(n/2)
gammaMax = [1+(i*step)];
end
gamma = [gammaMin 1 gammaMax];
i = 3;
for g = gamma
img_CS = imadjust(img_gray, stretchlim(img_gray, tol), [], g);
subplot(n+1,2,i);
imshow(img_CS)
title(['tol: ' num2str(tol) '. gamma: ' num2str(g)]);
subplot(n+1,2,i+1);
imhist(img_CS);
i = i + 2;
end
end
why the code use step = 1/n?why estimate gammaMin = [1-(i*step)] and gammaMax = [1+(i*step)]?

Answers (0)

Categories

Find more on Convert Image Type in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!