•
•
•
•
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
![]() |
•
•
Join Date: Feb 2005
Posts: 1
Reputation:
Rep Power: 0
Solved Threads: 0
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
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
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.
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.
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb Java Marketplace
- Something wrong with scanning of intesity value of pixel image (C#)
- pixel scanning (C++)
- Checking source codes of image, audio and video files (Site Layout and Usability)
- Checking source codes of image, audio and video files (C)
- Checking source codes of image, audio and video files (Graphics and Multimedia)
Other Threads in the Java Forum
- Previous Thread: Need help debugging program
- Next Thread: Breaking out of a Loop



Linear Mode