Jump to content

Regex for finding regions of identical colored adjacent pixels in images


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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.