一张图片经过matlab处理,imshow了之后会出现三幅一样的输出图像并排显示,而且彩色图片变成了黑白的
clear all
close all
clc
A = imread('pout.tif');
imshow(A);
minA = min(A(:));
maxA = max(A(:));
contrastA = maxA - minA
g1old = 70;
g2old =150;
g1new = 10;
g2new = 240;
a = g1new/g1old;
b = (g2new - g1new)/(g2old -g1old);
c = (255 - g2new)/(255 - g2old);
[r,c] =size(A);
B = zeros(r,c);
for x = 1:r
for y = 1:c
gold = A(x,y);
if gold < g1old
gnew = a*A(x,y);
elseif gold >= g1old & gold <= g2old
gnew = b*(gold - g1old) + g1new;
else
gnew = c*(gold - g2old) + g2new;
end
B(x,y) = gnew;
end
end
B = uint8(B);
figure
imshow(B);
minB = min(B(:));
maxB = max(B(:));
contrastB = maxB - minB
imwrite(B,'pout.jpg');
clear all
close all
clc
A = imread('pout.tif');
imshow(A);
minA = min(A(:));
maxA = max(A(:));
contrastA = maxA - minA
g1old = 70;
g2old =150;
g1new = 10;
g2new = 240;
a = g1new/g1old;
b = (g2new - g1new)/(g2old -g1old);
c = (255 - g2new)/(255 - g2old);
[r,c] =size(A);
B = zeros(r,c);
for x = 1:r
for y = 1:c
gold = A(x,y);
if gold < g1old
gnew = a*A(x,y);
elseif gold >= g1old & gold <= g2old
gnew = b*(gold - g1old) + g1new;
else
gnew = c*(gold - g2old) + g2new;
end
B(x,y) = gnew;
end
end
B = uint8(B);
figure
imshow(B);
minB = min(B(:));
maxB = max(B(:));
contrastB = maxB - minB
imwrite(B,'pout.jpg');