Skip to Main Content Skip to Search
Login
File Exchange
MATLAB Newsgroup
Link Exchange
  Blogs  
 Contest 
MathWorks.com

Thread Subject: How to Change the specified pixel value of an image?

Subject: How to Change the specified pixel value of an image?

From: Dawn

Date: 06 May, 2008 08:44:05

Message: 1 of 4

Here are 2 images. Original and Processed.

Original:
http://bp2.blogger.com/_dY9PPdeLapU/SCAXQJWgxYI/AAAAAAAAAKI/
oA9Pewda5rA/s320/original.bmp

Processed:
http://bp0.blogger.com/_dY9PPdeLapU/SCAYApWgxZI/AAAAAAAAAKQ/
yrSxCKYLlIs/s320/processed.bmp

I want to check the white pixels on the Processed Image
against the original. If they are white on the original,
make it black. If not keep them white.

The code I tried is like this:

>> [row, col] = find(Processed == 1); %Obtain the
coordinates of the white pixels
>> if Original(r,c) == 1 %If on the original the they are
white
Processed(r,c) = 0; %Make it black
end

Somehow the program doesn't work. It fails to remove any
pixel on the Processed Image.

Can anyone tell me what is wrong with the code?

Subject: Re: How to Change the specified pixel value of an image?

From: Dawn

Date: 06 May, 2008 08:51:03

Message: 2 of 4

The image links are incompletely highlighted.

Please visit:

http://dawnllc.blogspot.com/2008/05/matlab-how-to-change-
specified-pixel.html

to view the images regarding to the question.

Thanks very much.

Subject: Re: How to Change the specified pixel value of an image?

From: us

Date: 06 May, 2008 08:57:04

Message: 3 of 4

"Dawn ":
<SNIP a matter of logic...

one of the many solutions

% the images
     a=zeros(4); % the original...
     a(2,:)=1;
     b=a;
     b(2,[1,end])=0;
     b(3,:)=1; % the processed...
% the engine
     c=b;
     c(a&b)=0;
% the result
     a,b,c

us

Subject: Re: How to Change the specified pixel value of an image?

From: Dawn

Date: 10 May, 2008 06:02:26

Message: 4 of 4

"us " <us@neurol.unizh.ch> wrote in message <fvp6h0
$2rp$1@fred.mathworks.com>...

> % the engine
> c=b;
> c(a&b)=0;

This works. Thank you.

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
logical indexing us 06 May, 2008 05:00:25
and us 06 May, 2008 05:00:25
code us 06 May, 2008 05:00:25
pixel value image Dawn 06 May, 2008 04:45:22
rssFeed for this Thread

envelope graphic E-mail this page to a colleague

Public Submission Policy
NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Disclaimer prior to use.
Related Topics