Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8498615
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T00:27:05+00:00 2026-06-11T00:27:05+00:00

I have a binary image of several connected components, some large and some small

  • 0

I have a binary image of several connected components, some large and some small (maybe only 1 pixel). With this I am seeking a way to make each connected component into a checkers pattern, instead of the connected blobs, in an efficient way.

So far I have come up with two ways this could be tried, but they can either produce errors, or be quite unefficient:

  1. I know the entire image and can make a checkers pattern mask to remove 50% of the pixels. This is very fast, but will on average remove 50% of the connected components which are only one pixel in area.

  2. Use bwlabel() in MATLAB/Octave, and loop through each connected component only applying the mask to that component if it is over 1 pixel (while leaving the other components to be considered when the loop gets to them). This can be very inefficient.

Any smart/built-in solutions which could be used?

Example

Code to generate figure

T = zeros(40,40);
T(10:30,10:30) = 1;

chessVec = repmat([1;0],20,1);

T_wanted = (repmat([chessVec circshift(chessVec,1)],1,20).*T);

figure();
subplot(1,2,1);imshow(T);title('Start shape')
subplot(1,2,2);imshow(T_wanted);title('Wanted shape');
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T00:27:07+00:00Added an answer on June 11, 2026 at 12:27 am

    Nothing beats blanket checkering for efficiency. All you then need to do is add back the small connected components.

    %# create a test image
    img = rand(100)>0.8;
    img = imclose(img,ones(5));
    img = imerode(img,strel('disk',2));
    

    enter image description here

    %# get connected components
    %# use 4-connect to preserve
    %# the diagonal single-pixel lines later
    cc = bwconncomp(img,4)
    
    %# create checkerboard using one of Matlab's special matrix functions
    chk = invhilb(100,100) < 0;
    
    %# checker original image, add back small stuff
    img(chk) = 0;
    
    smallIdx = cellfun(@(x)x<2,cc.PixelIdxList);
    img([cc.PixelIdxList{smallIdx}]) = 1;
    

    enter image description here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to encode/compress some binary image data as a sequence if bits. (This
I have a small wxWidget application that uses image files at several places. I
I have a binary image with non closed curves of 1-pixel width on it.
i need some help with this problem. I have a binary tree stucture which
I have a binary image that represents a number in MATLAB: I'd like to
I have a binary image (a dll) which I wish to view the assembly
I have a binary image with contour lines and need to purify each contour
I have written a raw binary image file into a buffer which is an
I have a raw image file that is saved in binary data (no encoding).
I'm trying to display image data read in from a binary file (I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.