I have two small programs which must have the same result but in executing them I have some difference and I don't understand where is the problem. The task is to write a simple stand-alone program that converts the loaded source image in the negative one.
X=imread('mosque.jpg');imshow(X);[n,m]=size(X);B=zeros(n, m, 'uint8');for i=1:n for j=1:m B(i,j)=255-X(i,j); endendsubplot(2,2,1);imshow(X);subplot(2,2,2);imhist(X);subplot(2,2,3);imshow(B);subplot(2,2,4);imhist(B);
the second program without the for
X=imread('mosque.jpg');imshow(X);[n,m]=size(X);B=zeros(n, m, 'uint8'); B=255.-X; subplot(2,2,1);imshow(X);subplot(2,2,2);imhist(X);subplot(2,2,3);imshow(B);subplot(2,2,4);imhist(B);
Best Answer