User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Java section within the Software Development category of DaniWeb, a massive community of 374,011 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,717 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Java advertiser: Lunarpages Java Web Hosting
Views: 2759 | Replies: 2
Reply
Join Date: Feb 2005
Posts: 1
Reputation: PaulaS is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
PaulaS PaulaS is offline Offline
Newbie Poster

Help! Scanning through each image pixel...

  #1  
Feb 12th, 2005
Hi,

I have a project where we need to scan each pixel from an image. Somewhere in the image there will be a 10x10 red pixel and we need to draw a circle around it. This is the code I have so far: (but I'm having trouble figureing out the code to scan each pixel?) Any help would be great! Thanks

public static void main(String[] args) {

TheMatrix picture = new TheMatrix(EasyInput.openFileDialog());
int width = picture.getWidth();
int height = picture.getHeight();
int[] pixels;
for (int x = 0; x < width; x++){
for (int y = 0; y < height; y++){
Color c = picture.getColor(x, y);
if (c == Color.RED){
for (int x = 0; x < 199; ++x) {
int y = (int) (Math.sqrt(200 * 200 - x * x));
picture.setColor(250 + x, 250 + y, Color.WHITE);
picture.setColor(250 - x, 250 + y, Color.WHITE);
picture.setColor(250 + x, 250 - y, Color.WHITE);
picture.setColor(250 - x, 250 - y, Color.WHITE);
picture.show();
}


Paula
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Feb 2005
Location: eskisehir
Posts: 119
Reputation: tonakai is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 10
tonakai's Avatar
tonakai tonakai is offline Offline
Junior Poster

Re: Help! Scanning through each image pixel...

  #2  
Feb 16th, 2005
i don't quite understand your question and your program, but i understand this :
these is a 10 pixel x 10 pixel sized red square in a picture, we need to find it and draw a circle around it.
well we can solved like this, we need an 10x10 array which will hold the color values... also we need another 2d array which is for the circle, for example a 15x15, we need to fill this array only for once at the beginning.
we start to get every 10x10 from the picture and check if all of the values are RED. then when we found red square we put the circle-array over the red square...
that is the algorithm i found...
i hope i understand correctly.
Reply With Quote  
Join Date: Jun 2004
Location: H4x0rville
Posts: 2,105
Reputation: server_crash is on a distinguished road 
Rep Power: 9
Solved Threads: 18
server_crash's Avatar
server_crash server_crash is offline Offline
Postaholic

Re: Help! Scanning through each image pixel...

  #3  
Feb 16th, 2005
I think there is some method that takes an image, and creates an array of pixels out of it:

I think it's something like this:

int x = getPixels(Image);
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb Java Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the Java Forum

All times are GMT -4. The time now is 10:58 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC