% JPG_FunnyBiz

imshow('Tower.jpg')
shg

% Be careful with size...
A = imread('Tower.jpg');
[m,n,r] = size(A);
fprintf('m = %1d  n= %1d  r = %1d\n',m,n,r)
[m1,n1] = size(A);
fprintf('m = %1d  n= %1d  \n',m1,n1)

% Let's look at a patch of the image (the red part):
Patch_Before = A(295:300,97:113,1)

% Now let's put a magent strip down the image...
A(:,100:105,1) = 255;
A(:,100:105,2) = 0;
A(:,100:105,3) = 255;

% Let's revisit the patch...
Patch_After = A(295:300,95:110,1)

% Now save the modified image...
imwrite(A,'ModTower.jpg')
% And look at it...
imshow('ModTower.jpg')
% And read it back in...
ModA = imread('ModTower.jpg');
% And revisit the same patch..
ModPatch_After = ModA(295:300,95:110,1)
% It is not quite the same because the jpeg compression algorithm throws
% away a harmlessly small amount of information during the compression.
