How to assign a column of pixels a zero value?

I have a grayscale image.
I want to assign pixels of the first 30 columns in this image a value of zero. How can this be done?
Thanks.

 채택된 답변

Adam
Adam 2014년 9월 9일
편집: Adam 2014년 9월 9일

2 개 추천

data(:,1:30) = 0;

댓글 수: 2

Hamza Ahmed
Hamza Ahmed 2014년 9월 10일
편집: Hamza Ahmed 2014년 9월 10일
That worked, thanks!
Just one more question.. if I want to give the value of an area of pixels in the middle of image, and make everything else in the image=0
how would I write the code then?
Adam
Adam 2014년 9월 10일
편집: Adam 2014년 9월 10일
Assuming you mean a rectangular area and you know the indices within which you want the single value something like the following will work:
newImage = zeros( size( oldImage ) );
newImage( xMin:xMax, yMin:yMax ) = value;
where value is whatever value you wish to give to the region. Obviously here your original image is irrelevant to the process other than to provide the size, but that seems to be what you were asking?

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

질문:

2014년 9월 9일

편집:

2014년 9월 10일

Community Treasure Hunt

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

Start Hunting!

Translated by