pkg load image clear clc I = imread('cameraman.bmp'); I2 = I; count1 = 0; count2 = 0; for i = 1 : 256 for j = 1 : 256 if I(i,j) < 50 I2(i,j) = 2 * I(i,j); count1 = count1 + 1; end if I(i,j) > 200 I2(i,j) = I(i,j)/2; count2 = count2 + 1; endif endfor endfor noTransform = 65536 - count1 - count2; I2CS = imadjust(I2); I2HE = round(256*(histeq(I2))); subplot(2,2,1), imshow(I,[0 255]), title('Orginal') subplot(2,2,2), imshow(I2,[0 255]), title('Transformed') subplot(2,2,3), imshow(I2CS,[0 255]), title('Contrast Streched') subplot(2,2,4), imshow(I2HE,[0 255]), title('Histogram Equalized')