Change a single pixel value in a Grayscale JPEG image

3 ビュー (過去 30 日間)
LOKESH
LOKESH 2012 年 4 月 25 日
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?

採用された回答

Thomas
Thomas 2012 年 4 月 25 日
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 件のコメント
LOKESH
LOKESH 2012 年 4 月 25 日
Thanks I made mistake while reading axes..

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeImages についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by