<< Chapter < Page Chapter >> Page >

(Instructions for writing an image explorer sketch were provided in Pr0120-Image Explorer .)

Program output

Image 1 shows the raw image being displayed in an image explorer window. Note the red, green, and blue color component values and the coordinates of the pixel to which those colors belong.

Image 1. the raw image displayed in an image explorer.

The raw image displayed in an image explorer.
Image 1. The raw image displayed in an image explorer.

Image 2 shows the modified image in an image explorer window. Once again, note the red, green, and blue colorcomponent values and the coordinates of the pixel to which those colors belong.

Image 2. the modified image displayed in an image explorer.

The modified image displayed in an image explorer.
Image 2. The modified image displayed in an image explorer.

The algorithm

The algorithm required to transform the image from Image 1 to Image 2 is:

  • Set the blue color value for every pixel to zero.
  • Invert the red and green color values for every pixel.

A color value is inverted by subtracting the color value from 255.

Obvious that the blue color value is reduced to zero

By exploring the pixel colors at several different locations, it should be obvious to the student that the blue pixel value has been set to zero forevery pixel in the modified image.

Color inversion is not quite so obvious

Deducing that the red and green colors in the output pixels are the inverse of the red and green colors in the input image isn't as straightforward.However, color inversion is one of the most common forms of image color manipulation, so a little research on the web should suffice to figure it out. I have also publishedseveral online tutorials that involve color inversion.

The implementation of the algorithm will be explained below.

Discussion and sample code

Will explain in fragments

This sketch consists of two classes, which are provided in Listing 4 and Listing 5 .

I will break the sketch down and explain it in fragments.

The driver class named Pr0130a

The driver class named Pr0130a , which is shown in its entirety in Listing 4 , is almost exactly like the class that I explained in Pr0120-Image Explorer . Therefore, I won't repeat that explanation in this module.

The runner class named Pr0130aRunner

The runner class named Pr0130aRunner is shown in Listing 5 . This class is only slightly different from the class that I explained in Pr0120-Image Explorer . Therefore, I will explain only those portions of the class that are different inthis module.

The first difference

The first difference begins within the for loop shown in Listing 1 . Recall that in the original version in Pr0120-Image Explorer , the code in the for loop copied pixel colors from the input image to the output image taking the different widths of the images intoaccount.

This version is essentially the same except that in this version, the code inverts the red and green color values and sets the blue color value to zerobefore inserting the pixel color into the output image.

Listing 1. copy pixel colors from the input image to the display image.

//Copy pixel colors from the input image to the // display image.for(int cnt = 0;cnt<img.pixels.length;cnt++){ //Get and save RGB color values for current pixel.reD = red(img.pixels[cnt]);greeN = green(img.pixels[cnt]);bluE = blue(img.pixels[cnt]);//color c = color(reD, greeN, bluE);//raw color c = color(255-reD, 255-greeN, 0);//modified
Listing 1. Copy pixel colors from the input image to the display image.

Questions & Answers

what is Nano technology ?
Bob Reply
write examples of Nano molecule?
Bob
The nanotechnology is as new science, to scale nanometric
brayan
nanotechnology is the study, desing, synthesis, manipulation and application of materials and functional systems through control of matter at nanoscale
Damian
Is there any normative that regulates the use of silver nanoparticles?
Damian Reply
what king of growth are you checking .?
Renato
What fields keep nano created devices from performing or assimulating ? Magnetic fields ? Are do they assimilate ?
Stoney Reply
why we need to study biomolecules, molecular biology in nanotechnology?
Adin Reply
?
Kyle
yes I'm doing my masters in nanotechnology, we are being studying all these domains as well..
Adin
why?
Adin
what school?
Kyle
biomolecules are e building blocks of every organics and inorganic materials.
Joe
anyone know any internet site where one can find nanotechnology papers?
Damian Reply
research.net
kanaga
sciencedirect big data base
Ernesto
Introduction about quantum dots in nanotechnology
Praveena Reply
what does nano mean?
Anassong Reply
nano basically means 10^(-9). nanometer is a unit to measure length.
Bharti
do you think it's worthwhile in the long term to study the effects and possibilities of nanotechnology on viral treatment?
Damian Reply
absolutely yes
Daniel
how to know photocatalytic properties of tio2 nanoparticles...what to do now
Akash Reply
it is a goid question and i want to know the answer as well
Maciej
characteristics of micro business
Abigail
for teaching engĺish at school how nano technology help us
Anassong
Do somebody tell me a best nano engineering book for beginners?
s. Reply
there is no specific books for beginners but there is book called principle of nanotechnology
NANO
what is fullerene does it is used to make bukky balls
Devang Reply
are you nano engineer ?
s.
fullerene is a bucky ball aka Carbon 60 molecule. It was name by the architect Fuller. He design the geodesic dome. it resembles a soccer ball.
Tarell
what is the actual application of fullerenes nowadays?
Damian
That is a great question Damian. best way to answer that question is to Google it. there are hundreds of applications for buck minister fullerenes, from medical to aerospace. you can also find plenty of research papers that will give you great detail on the potential applications of fullerenes.
Tarell
what is the Synthesis, properties,and applications of carbon nano chemistry
Abhijith Reply
Mostly, they use nano carbon for electronics and for materials to be strengthened.
Virgil
is Bucky paper clear?
CYNTHIA
carbon nanotubes has various application in fuel cells membrane, current research on cancer drug,and in electronics MEMS and NEMS etc
NANO
so some one know about replacing silicon atom with phosphorous in semiconductors device?
s. Reply
Yeah, it is a pain to say the least. You basically have to heat the substarte up to around 1000 degrees celcius then pass phosphene gas over top of it, which is explosive and toxic by the way, under very low pressure.
Harper
Do you know which machine is used to that process?
s.
how to fabricate graphene ink ?
SUYASH Reply
for screen printed electrodes ?
SUYASH
What is lattice structure?
s. Reply
of graphene you mean?
Ebrahim
or in general
Ebrahim
in general
s.
Graphene has a hexagonal structure
tahir
On having this app for quite a bit time, Haven't realised there's a chat room in it.
Cied
how did you get the value of 2000N.What calculations are needed to arrive at it
Smarajit Reply
Privacy Information Security Software Version 1.1a
Good
Got questions? Join the online conversation and get instant answers!
Jobilize.com Reply

Get the best Algebra and trigonometry course in your pocket!





Source:  OpenStax, The processing programming environment. OpenStax CNX. Feb 26, 2013 Download for free at http://cnx.org/content/col11492/1.5
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'The processing programming environment' conversation and receive update notifications?

Ask