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

Thread Subject: Black and white switch

Subject: Black and white switch

From: Phil Au

Date: 29 Feb, 2008 00:09:06

Message: 1 of 4

Hi all,

Does anyone know that a way to turn a logical image or
uint8 image, from black background to white background from
white line to black line in a simple step??

Thx a lot

Subject: Re: Black and white switch

From: Matthew Whitaker

Date: 29 Feb, 2008 00:44:09

Message: 2 of 4

"Phil Au" <philipawt@gmail.com> wrote in message <fq7if2
$nmt$1@fred.mathworks.com>...
> Hi all,
>
> Does anyone know that a way to turn a logical image or
> uint8 image, from black background to white background
from
> white line to black line in a simple step??
>
> Thx a lot

imshow(L)

imshow(~L)%where L is a logical image

imshow(u8)
imshow(intmax(class(u8))-u8) %where u8 is a uint8 image

Hope this helps
Matt

Subject: Re: Black and white switch

From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)

Date: 04 Mar, 2008 21:18:52

Message: 3 of 4

In article <fq7kgp$j2a$1@fred.mathworks.com>,
Matthew Whitaker <mattlwhitaker@REMOVEgmail.com> wrote:
>"Phil Au" <philipawt@gmail.com> wrote in message <fq7if2
>$nmt$1@fred.mathworks.com>...

>> Does anyone know that a way to turn a logical image or
>> uint8 image, from black background to white background
>from
>> white line to black line in a simple step??

>imshow(u8)
>imshow(intmax(class(u8))-u8) %where u8 is a uint8 image

Unfortunately that last line does not generalize to int8
as might be hinted by the use of intmax(class(u8)) instead than
the hardcoding of the constant 255.

This generalizes a little better, provided T is one of the int classes.

reshape(typecast(bitxor(typecast(T(:),'uint8'),uint8(255)),class(T)),size(T))
--
  "There are some ideas so wrong that only a very intelligent person
  could believe in them." -- George Orwell

Subject: Re: Black and white switch

From: Vihang Patil

Date: 05 Mar, 2008 05:22:01

Message: 4 of 4

"Phil Au" <philipawt@gmail.com> wrote in message <fq7if2
$nmt$1@fred.mathworks.com>...
> Hi all,
>
> Does anyone know that a way to turn a logical image or
> uint8 image, from black background to white background
from
> white line to black line in a simple step??
>
> Thx a lot


doc imcomplement

HTH
VIhang

Tags for this Thread

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.

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