Path: news.mathworks.com!newsfeed-00.mathworks.com!news.kjsl.com!newsfeed.stanford.edu!elk.ncren.net!newsflash.concordia.ca!canopus.cc.umanitoba.ca!not-for-mail
From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)
Newsgroups: comp.soft-sys.matlab
Subject: Re: Black and white switch
Date: Tue, 4 Mar 2008 21:18:52 +0000 (UTC)
Organization: National Research Council Canada - Conseil national de rechereches Canada
Lines: 23
Message-ID: <fqkebs$l77$1@canopus.cc.umanitoba.ca>
References: <fq7if2$nmt$1@fred.mathworks.com> <fq7kgp$j2a$1@fred.mathworks.com>
NNTP-Posting-Host: origin.ibd.nrc.ca
X-Trace: canopus.cc.umanitoba.ca 1204665532 21735 192.70.172.160 (4 Mar 2008 21:18:52 GMT)
X-Complaints-To: abuse@cc.umanitoba.ca
NNTP-Posting-Date: Tue, 4 Mar 2008 21:18:52 +0000 (UTC)
Originator: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)
Xref: news.mathworks.com comp.soft-sys.matlab:455378


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