Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

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: 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: Black and white switch

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

Date: 4 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: Black and white switch

From: Vihang Patil

Date: 5 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

No tags are associated with this thread.

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.

Contact us