Drawing an image with icons

Hey Everyone, just a quick question… If I want to draw an image with a set of icons that I have, and I want the image to analize the colors in the icons and use the appropriate icon when it matches the color of the area that is being drawn.

Can someone please help?

Thanks a lot

Which part of this is giving you trouble?

Have you searched in the reference for image functions? It sounds like you’re looking for the loadImage() and image() functions.

Shameless self-promotion: here is a guide on using images in Processing.

When you want to replace each pixel in the image with an icon (1) OR replace a small rectangle in the original image with an icon (2):

For loop over all the pixels in image

Use get() to get the color of pixel (see reference)

For loop over all pixels in icon and get average color of icon using get() - for speed consideration for loop over all icons first and store average color for each icon and then compare to pixel color

Choose icon with nearest color to pixel

Calculate the average color of rectangle using for loop with get

@Kevin Thanks for your answer.
I am looking for something like this
image mosaic

I’ve edited your post to remove the NSFW image, as many people here post from work and I don’t want anybody getting fired. If the image I chose is not quite correct, please edit in a safe for work version.

Anyway, which part of this are you stuck on? It’s hard to help with general “how do I do this” type questions. You’ll have much better luck if you break your problem down into smaller steps and take those steps on one at a time.

For example, can you create an algorithm that breaks your image down into a grid of colors? Don’t worry about breaking it down into smaller images yet. Just take each section of your image (for example, each section could be 100x100 pixels) and extract a representative color for that section.

There are a bunch of different ways to do that. Start your research there, and try to get just that step working. Then if you get stuck, you can post a MCVE along with a specific technical question. Good luck!