MATLAB: Change a pixle color

digital image processingimage processingImage Processing ToolboxMATLAB

I use this code to do it: if true
clear all;
clc;
im = imread('C:\Users\Arash\Desktop\11.jpg');
info = imfinfo('C:\Users\Arash\Desktop\11.jpg');
H = info.Height;
W = info.Width;
CP = ceil(W / 2);
RP = ceil(H / 2);
im(RP,CP,1)=0;
im(RP,CP,2)=255;
im(RP,CP,3)=0;
imshow(im);
im(RP,CP,1)
im(RP,CP,2)
im(RP,CP,3)
imwrite(im,'C:\Users\Arash\Desktop\11.jpg');
figure(2);imshow('C:\Users\Arash\Desktop\11.jpg');
end
But when I open it again after storage is no longer a trace of change

Best Answer

Remember that jpeg is a lossy storage format. A change to a single pixel would be high frequency noise that would get smoothed out.
If it is mandatory that you store in jpeg, then when you imwrite() give the option for lossless compression (which is not efficient in jpeg.)
If you are allowed to use other file formats then use TIFF or PNG.