Jump to content

Regex for finding regions of identical colored adjacent pixels in images


dsaba

Recommended Posts

I'm trying to identify the regions of ranges or coordinates where there are adjacent pixels of the same color. In simpler terms, the regions in an image where it is filled by a solid color. The image can have any number of different regions in any number of particular colors.

 

I thought about parsing each pixel in a loop with imagecolorat() to find out where these regions are.

However, I realized since I'm looking for a patterns, why not let regex do the work for me? The images are 6-10kb, so its not that much data for regex to deal with.

 

The input images are coming in originally in GIF format, but with PHP's image functions I'm capable of converting them to any format like JPEG or PNG. This is another thing I'm not sure about: What image format is best to work with when looking at raw image data to see patterns of the same colored pixels?

 

Surely some knowledge of the way these image formats are structured will be helpful in creating a regex for this. If you have a better idea for quickly identifying these regions other than the two I mentioned, I'd love to hear it as well.

 

So how do I go about doing this, even possible?

 

-thanks.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.