Help Please!!!! (Magic Wand assignment)

edited November 2017 in How To...

So I have an assignment that requires me to do this:

This assignment is for Image Processing practice.

Q1. (100 Points) Please use Processing to write an Image Color Selection Application (create your own “Magic Wand”) - your application should be able to:

(1) Display the given image (“sunflower.jpg”);

(2) The application window size should be no smaller than 800 * 600 (the given image size is 600 * 600);

(3) There should be a color selection button - once this button is clicked, you can use the mouse hover over the image to particularly pick a pixel color, using mouse click on that specific pixel;

(4) There should be another pixel selection button (that after you selected a pixel color) - once you click on the button, all pixels within the entire image whose color is close to the color picked will be highlighted in red (if the color distance between the pixel color and picked color is smaller or equal to 50).

Deliverables:

Turn in your Processing code files (.pde file(s)); together with the result images.

I have to be able to basically create a magic wand but I don't really know what I'm doing to even begin creating this. Is there anyone that can help me get started and point me in the right direction?

Answers

  • post what you have.

    we are not going to just do your assignment for you, you have to at least attempt it first.

  • I am working on this same project. The code I have so far:

    PImage img;

    void setup() { size(800, 600); img = loadImage("sunflower.jpg"); }

    void draw() { image(img, 0, 0); if (mousePressed && (mouseButton == LEFT)) { fill(0); } else if (mousePressed && (mouseButton == RIGHT)) { fill(255); } else { fill(126); } rect(650, 275, 50, 50); rect(650, 450, 50, 50); }

    I want to make the 1st button where when the mouse clicks it, it turns black and the mouse hovers over the image to particularly pick a pixel color, using mouse click on that specific pixel. For the second button, I want it to where when the mouse clicks it, it turns white and all pixels within the entire image whose color is close to the color picked will be highlighted in red (if the color distance between the pixel color and picked color is smaller or equal to 50). Right now, both of the buttons turn black when the left button on mouse id clicked and turn white when the right button is clicked.

  • Learn how to format the code right in your post

    Go back edit your post (click small gear/edit)

    Empty line before and after the code

    Select entire code

    Hit ctrl-o

    The code: You need to store the color you want in a variable and use this variable before rect() to make color permanent

    Also look at function mousePressed() in the reference- not the variable with the same name

    You can look into the reference and recognize the function mousePressed () by its brackets ()

    Also when you mean screen buttons you should look at the examples on the website for mouse/ buttons.

    In short: check the mouse position against the button position using if(mouseX>650&&mouseY>450&&mouseX<...... &&mouseY< ......)

Sign In or Register to comment.