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.

 Akzeptierte Antwort

Adam
Adam am 9 Sep. 2014
Bearbeitet: Adam am 9 Sep. 2014

2 Stimmen

data(:,1:30) = 0;

2 Kommentare

Hamza Ahmed
Hamza Ahmed am 10 Sep. 2014
Bearbeitet: Hamza Ahmed am 10 Sep. 2014
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 am 10 Sep. 2014
Bearbeitet: Adam am 10 Sep. 2014
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?

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Gefragt:

am 9 Sep. 2014

Bearbeitet:

am 10 Sep. 2014

Community Treasure Hunt

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

Start Hunting!

Translated by