File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes scanning an image for a certain pixel color in java Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "scanning an image for a certain pixel color in java" Watch "scanning an image for a certain pixel color in java" New topic
Author

scanning an image for a certain pixel color in java

me erum
Greenhorn

Joined: Feb 05, 2012
Posts: 2
I'm working on a project and quiet new to java. I want to scan an image pixel by pixel for a certain color, i.e. cyan and then print the coordinates of that pixel color. The code runs, creates an output file but doesn't write anything to it. Can somebody please help me with it to find the errors. I also want to know how to read a .tiff file in java while using the same code.

Java Code:
Jesper de Jong
Java Cowboy
Bartender

Joined: Aug 16, 2005
Posts: 11642

Welcome to the Ranch.

These masks look wrong:

Red is in bits 16-23; green is in bits 8-15; blue is in bits 0-7. It should be:

Also, you should call close() on out at the end of the program.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 3221


When is a r/g/b component ever greater than 255?


luck, db
There are no new questions, but there may be new answers.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 26720
Darryl Burke wrote:

When is a r/g/b component ever greater than 255?
When I try to explain to our undergraduates that new Color(0, 0xff00, 0) if it ever gets past the runtime will not set the colour to a brighter green than normal, but to red.

By the way: I think you ought not to use 255. I prefer to use 0xff. These numbers are demoninated in hex, so I think they ought to be assessed in hex.
Randall Twede
Ranch Hand

Joined: Oct 21, 2000
Posts: 3905
for reading .tiff files try ImageIO class.


I never took notes in college. That's how I got a 4.0 the first 2 years, and a 3.5 the second two years.
Jesper de Jong
Java Cowboy
Bartender

Joined: Aug 16, 2005
Posts: 11642

Randall Twede wrote:for reading .tiff files try ImageIO class.

He's already using the ImageIO class (to read a JPG image, in his code above). Unfortunately the JDK doesn't come with support for the TIFF format (the only formats that ImageIO can read without extra plug-ins are: JPG PNG BMP WBMP GIF) - see the API docs for the package javax.imageio.

 
 
subject: scanning an image for a certain pixel color in java
 
Threads others viewed
Picture Manipulation Methods
Logical operation on Image
How to code a button with image
How do i find out what color a certain pixel is?
getting the color of a particular pixel from an image loaded in applet
IntelliJ Java IDE

cast iron skillet 49er

more from paul wheaton's glorious empire of web junk: cast iron skillet diatomaceous earth rocket mass heater sepp holzer raised garden beds raising chickens lawn care CFL flea control missoula heat permaculture