Jump to content

read and write array in for loop


thinhare

Recommended Posts

Hello, everyone,

Here is my problem: I'd like to implement "connected component labeling" algorithm to analyze particles in a binary bitmap image.

each time a pixel is read, if it is black, the original valus is kept;

if it is white, and if its 8 neighoring pixels are all black, an unique id is assigned to the pixel;

if one or more of 8 neighboring pixels are white too, then find out the ids of those pixels, and pick the lowest one assign to the current/central pixel.

therefore, each time 9 values out of the image array will be read and the assigned id will be written back to the array.

attached you can find my implementation, strangely enough that it is slow, and the id seems never changes (I set the starting value as 10000).

Any idea?

Thanks.

thinhare

Link to comment

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.   Paste as plain text instead

  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

By using this site, you agree to our Terms of Use.