Novice Question: Image processing. expected a "mosaic"; got "grey"
in
Programming Questions
•
8 months ago
Good evening All.
I've literally started playing with processing this evening (2 hours or so) so please excuse me if my questions are REALLY stupid.
I am making a polargraphic plotter using an arduino (the physical arduino side of it i have working fine) and am venturing into the world of processing to process the images i wish to plot, into workable serial data (which i will then push into the arduino, or at least, thats the plan)
Because of the way a polargraphic plotter works, i have decided to rotate the image 45 degrees left, and centre it on a frame bigger than it needs.
this "setup" part of the sketch works fine, and gives the result i want.
I then want to process the image into much larger "pixels", which will then be used to proved lower resolution greyscale data.
i initially tried just to resize the image, but it wasnt very successful, and i want the option of controlling how the pixels are averaged in the future, so i am going for the effect shown in the "get()" tutorial:
I want to scan down the image, which is 300 x 300 px, and fill squares 10 px by 10 px, with the colour of the underlying image (at this time, i am just taking the pixel in the middle of each 10 x 10 square)
When i run the sketch, the image i have loaded loads briefly in the background, but is then overlaid by 30 x 30 squares of flat grey.
can anyone point out what i have done wrong, i am currently bashing at trial and error and not really getting anywhere.
here is my sketch:
Thanks
Olly
I've literally started playing with processing this evening (2 hours or so) so please excuse me if my questions are REALLY stupid.
I am making a polargraphic plotter using an arduino (the physical arduino side of it i have working fine) and am venturing into the world of processing to process the images i wish to plot, into workable serial data (which i will then push into the arduino, or at least, thats the plan)
Because of the way a polargraphic plotter works, i have decided to rotate the image 45 degrees left, and centre it on a frame bigger than it needs.
this "setup" part of the sketch works fine, and gives the result i want.
I then want to process the image into much larger "pixels", which will then be used to proved lower resolution greyscale data.
i initially tried just to resize the image, but it wasnt very successful, and i want the option of controlling how the pixels are averaged in the future, so i am going for the effect shown in the "get()" tutorial:
I want to scan down the image, which is 300 x 300 px, and fill squares 10 px by 10 px, with the colour of the underlying image (at this time, i am just taking the pixel in the middle of each 10 x 10 square)
When i run the sketch, the image i have loaded loads briefly in the background, but is then overlaid by 30 x 30 squares of flat grey.
can anyone point out what i have done wrong, i am currently bashing at trial and error and not really getting anywhere.
here is my sketch:
- PImage img1;
- int x = 0;
- int y = 0;
- void setup() {
- size(500, 500); // frame is 500 x 500
- pushMatrix();
- // Make a new instance of a PImage by loading an image file
- img1 = loadImage("STRS.jpg"); // stormtrooper image, 300 x 300
- translate(250, 250); // moves pivot to keep central
- rotate(radians(315)); // rotates 45 degrees ACW
- imageMode(CENTER);
- image(img1, 0, 0); // draws the image
- }
- void draw() {
- for (int x = 0; x < 500; x = x + 10 ) {
- for (int y = 0; y < 500; y = y + 10) {
- color c = get(x + 5, y + 5);
- fill(c);
- stroke(100); // bounded by a box, dark grey
- rect(x, y, x + 10, y + 10);
- }
- }
- }
Thanks
Olly
1