Hello,
I want to extract the rgb color information from a jpg image do some processing and then construct the image back. I did it and i wanted to check the changes before and after then i noticed that there is something went wromg. So to cut to the chase, I just want to know why the following simple task is not as i expect it to be? What did i miss?
img=imread('IMGs/HD1.jpg');
r=img(:,:,1);
g=img(:, :, 2);
b=img(:,:,3);
rgb=cat(3,r,g,b);
imwrite(rgb,'IMGs/test.jpg');
MyImage = imread('IMGs/HD1.jpg');
MarkedImage = imread('IMGs/test.jpg');
MyRedChannel = MyImage(:, :, 1);
MarkedRedChannel = MarkedImage(:, :, 1);
MyRedChannel = reshape(MyRedChannel', 1, []);
MarkedRedChannel = reshape(MarkedRedChannel', 1, []);
[r,c] = find(MyRedChannel~=MarkedRedChannel);
MyRedChannel = reshape(MyRedChannel', 1, []);
MarkedRedChannel = reshape(MarkedRedChannel', 1, []);
[r,c] = find(MyRedChannel~=MarkedRedChannel);
///////////////////////////////////////////////////////////////////////////////////////////////////
The result: c=1×4655332 double
///////////////////////////////////////////////////////////////////////////////////////////////////
What i expect is to have c=[], empty. Because i just isolated the color information and reconstruct the image without any change. But obviously there is something that i'm missing something about the jpg structure.
Best Answer