MATLAB: How to change the certain pixel values in gray scale image

grayimage processing

%I have gray image X having values between 0 and 0 to 1, I want to change the values of certain pixel to 1 that are closer to 1 and want to change values to 0 that are near to 0. Can anyone write a code for that as I am new to matlab. Thanks

Best Answer

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