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

  • Home
  • SEARCH
  • 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 7081041
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:52:11+00:00 2026-05-28T06:52:11+00:00

This is the processed image and I can’t increase the bwareaopen() as it won’t

  • 0

This is the processed image and I can’t increase the bwareaopen() as it won’t work for my other image.

Anyway I’m trying to find the shortest points in the centre points of the barcode, to get the straight line across the centre points in the barcode.

Example:
After doing a centroid command, the points in the barcode are near to each other. Therefore, I just wanted to get the shortest points(which is the barcode) and draw a straight line across.

All the points need not be join, best fit points will do.

Step 1

a busy cat

Step 2

a busy cat

Step 3

a busy cat

  • 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-05-28T06:52:11+00:00Added an answer on May 28, 2026 at 6:52 am

    If you dont have the x,y elements Andrey uses, you can find them by segmenting the image and using a naive threshold value on the area to avoid including the number below the bar code.

    I’ve hacked out a solution in MATLAB doing the following:

    1. Loading the image and making it binary
    2. Extracting all connected components using bwlabel().
    3. Getting useful information about each of them via regionprops() [.centroid will be a good approximation to the middel point for the lines].
    4. Thresholded out small regions (noise and numbers)
    5. Extracted x,y coordinates
    6. Used Andreys linear fit solution

    Code:

    set(0,'DefaultFigureWindowStyle','docked');
    close all;clear all;clc;
    Im = imread('29ekeap.jpg');
    Im=rgb2gray(Im);
    %%
    
    %Make binary
    temp = zeros(size(Im));
    temp(Im > mean(Im(:)))=1;
    Im = temp;
    
    %Visualize
    f1 = figure(1);
    imagesc(Im);colormap(gray);
    
    %Find connected components
    LabelIm = bwlabel(Im);
    
    RegionInfo = regionprops(LabelIm);
    
    %Remove background region
    RegionInfo(1) = [];
    
    %Get average area of regions
    AvgArea = mean([RegionInfo(1:end).Area]);
    
    %Vector to keep track of likely "bar elements"
    Bar = zeros(length(RegionInfo),1);
    
    %Iterate over regions, plot centroids if area is big enough
    for i=1:length(RegionInfo)
       if RegionInfo(i).Area > AvgArea 
           hold on;
           plot(RegionInfo(i).Centroid(1),RegionInfo(i).Centroid(2),'r*')
           Bar(i) = 1;
       end
    end
    
    %Extract x,y points for interpolation
    X = [RegionInfo(Bar==1).Centroid];
    X = reshape(X,2,length(X)/2);
    
    x = X(1,:);
    y = X(2,:);
    
    %Plot line according to Andrey
    p = polyfit(x,y,1);
    xMin = min(x(:));
    xMax = max(x(:));
    xRange = xMin:0.01:xMax;
    yRange = p(1).*xRange + p(2);
    plot(xRange,yRange,'LineWidth',2,'Color',[0.9 0.2 0.2]);
    

    The result is a pretty good fitted line. You should be able to extend it to the ends by using the ‘p’ polynomal and evaluate when you dont encounter any more ‘1’s if needed.

    Result:

    enter image description here

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

Sidebar

Related Questions

How does this program access other processes memory? How can it write into the
Can anyone see why this would work in FF but not Safari? When I
Can someone tell me why this processes all the files and then does it
I need to know how you can find out when all processes (loaded) from
I am trying to save out a large image from flash using bitmapdata and
This might be a simple problem but I can't manage to solve it. I've
This is a bit maddening. I have code which saves the current background-image from
I'm trying to figure out the name behind this design pattern. Basically, you have
I'm trying to combine the capability of doing image zoom/panning inside of a Gallery
Can I create Instagram-esque filters with javascript? The images can be processed client-side or

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.