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.

 Accepted Answer

Adam
Adam on 9 Sep 2014
Edited: Adam on 9 Sep 2014
data(:,1:30) = 0;

2 Comments

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?
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?

Sign in to comment.

More Answers (0)

Asked:

on 9 Sep 2014

Edited:

on 10 Sep 2014

Community Treasure Hunt

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

Start Hunting!