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 729925
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T06:51:12+00:00 2026-05-14T06:51:12+00:00

So I have what is essentially a spreadsheet in TIFF format. There is some

  • 0

So I have what is essentially a spreadsheet in TIFF format. There is some uniformity to it…for example, all the column widths are the same. I want to de-limit this sheet by those known-column widths and basically create lots of little graphic files, one for each cell, and run OCR on them and store it into a database. The problem is that the horizontal lines are not all the same height, so I need to use some kind of graphics library command to check if every pixel across is the same color (i.e. black). And if so, then I know I’ve reached the height-delimiter for a cell. How would I go about doing that? (I’m using RMagick)

  • 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-14T06:51:12+00:00Added an answer on May 14, 2026 at 6:51 am

    Use image#get_pixel: http://www.simplesystems.org/RMagick/doc/image2.html#get_pixels
    Warning: Those docs are old, so it may have changed in the newer versions. Look at your own rdocs using $ gem server, assuming they have rdocs.

    image#rows gives you the height of the image, then you can do something like (untested):

    def black_line?(pixels)
      pixels.each do |pixel| 
        unless pixel.red == 0 && pixel.green == 0 && pixel.blue == 0
          return false
        end
      end
      true
    end 
    
    black_line_heights = []
    height = image.rows
    width = image.columns
    height.times do |y|
      pixels = image.get_pixel(0,y,width,1)
      black_line_heights << y if black_line?(pixels)
    end 
    

    Please keep in mind that I’m not sure about the api. Looking at older docs, and I can’t test it now. But it looks like the general approach you would take. BTW, it assumes the row borders are 1 pixel thick. If not, change the 1 to the actual thickness and that might be enough to make it work like you expect.

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

Sidebar

Related Questions

I have a simple class that essentially just holds some values. I have overridden
I have a mockup layout for something here . Essentially there are sections, columns
We have a reverse proxy here, running Apache in version 2.2.x Essentially I want
Update : I appreciate all of the comments, which have essentially comprised unanimous opposition.
I have essentially a survey that is shown, and people answer questions a lot
If you have to use String.Replace() to replace test 50 times, you essentially have
I have what is essentially a jagged array of name value pairs - i
I am currently trying to manipulate a unordered list with jQuery, essentially I have
i have a Sharepoint feature that essentially extends Lists with a new feature, using
Essentially, I have to get a flat file into a database. The flat files

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.