Change a single pixel value in a Grayscale JPEG image

3 vues (au cours des 30 derniers jours)
LOKESH
LOKESH le 25 Avr 2012
I have a grayscale jpeg image X. I want to change its pixel value. For example change pixel at (14,20) to 1,How can I do it. I tried the following but it doesn't WORK:
Xc=X; %Xc is image with a pixel value changed from X[X is original image]
X(14,20); %What is the value at 14,20
Xc(14,20)=1 %Change Pixel value at 14,20 to 1
When i view its values in Variable Editor,I don't get value changed at (14,20) in Xc image.
What are the Errors or suggestion?

Réponse acceptée

Thomas
Thomas le 25 Avr 2012
Are you sure you are checking Xc in the variable editor, you might be checking X (original image). the above does work..
I have tried
X=imread('1.jpg') % My image was color so was MxNxP
Xc=X(:,:,1) % crateda grayscale image MxN
Xc(14,20) % here my output was ans=129
Xc(14,20)=1 % changed the value of (14,20) to 1
Xc(14,20) % here my output was ans=1
If I change a block of values in Xc to 1 and do the imshow(Xc) - gives me a black box..
  1 commentaire
LOKESH
LOKESH le 25 Avr 2012
Thanks I made mistake while reading axes..

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Images dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by