ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 identify area
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

AndNit

Brazil
70 Posts

Posted - Jun 14 2024 :  10:09:07  Show Profile  Reply
Good afternoon

I need help. How to identify the end of the last line typed in an image, and identify exactly the starting point of the next line?

In the attached image, I put an example of what I need. Identify exactly the area in red, with the aim of creating a text box and sequencing the texts starting from the last line found.

I thought about scanning the document from beginning to end (vertical and horizontal), calculating the Histogram to know the starting point, but would there be a less laborious solution?

thanks

xequte

38319 Posts

Posted - Jun 14 2024 :  18:21:02  Show Profile  Reply
Hi

I'm not sure if there is a better solution other than parsing the scanlines, calculating the percentage of "White/blank" and then stop once you locate n consective rows of > z% "White/blank"

Nigel
Xequte Software
www.imageen.com
Go to Top of Page

AndNit

Brazil
70 Posts

Posted - Jun 15 2024 :  07:26:58  Show Profile  Reply
in this case I would use GetDominantColor, correct? How to do this, in an area x of the image? in this case, only in the selected area of the image.

thanks
Go to Top of Page

xequte

38319 Posts

Posted - Jun 15 2024 :  18:10:12  Show Profile  Reply
No, i think you would be better to write your own method using TIEBitmap.Scanline:

http://www.imageen.com/help/TIEBitmap.Scanline.html

Something like (untested)...

// Search the image for consecutive rows of mostly white
function FindConsecutiveWhiteRows(MinWhiteValue: Integer; MinConsecutiveWhiteRows: Integer; out WhiteRowsStart: Integer; out WhiteRowsEnd: Integer): Boolean; 
var
  x, y: Integer;
  pPix: PRGB;
  Gray: Byte;
  rowIsWhite: Boolean;
  consecutiveWhiteRows: Integer;
begin
  Result := False;
  WhiteRowsStart := 0;
  WhiteRowsEnd   := 0;

  consecutiveWhiteRows := 0;
  for y := 0 to ImageEnView1.IEBitmap.Height - 1 do
  begin
    pPix := ImageEnView1.IEBitmap.ScanLine[ y ];
    rowIsWhite := True;
    for x := 0 to ImageEnView1.IEBitmap.Width - 1 do
    begin
      if (pPix^.R < White_MinWhiteValue ) or (pPix^.G < MinWhiteValue ) or (pPix^.B < MinWhiteValue ) then
      begin    
        rowIsWhite := False;
        Break;
      end;
      inc( pPix );
    end;
    if rowIsWhite then 
      inc( consecutiveWhiteRows )
    else
      consecutiveWhiteRows := 0;

    if consecutiveWhiteRows >= MinConsecutiveWhiteRows then
    begin
      Result := True;
      WhiteRowsStart := y - consecutiveWhiteRows + 1;
      WhiteRowsEnd   := y;
      exit;
    end;
  end;
end;


Nigel
Xequte Software
www.imageen.com
Go to Top of Page

AndNit

Brazil
70 Posts

Posted - Jun 17 2024 :  14:07:45  Show Profile  Reply
Thanks for the help Nigel, but the way you put it, I couldn't understand or advance the solution lol... would we be able to work with GetDominantColor only in the area selected in the image? I think this way I can progress better, considering that all my images will be black and white
Go to Top of Page

xequte

38319 Posts

Posted - Jun 17 2024 :  18:54:02  Show Profile  Reply
Hi

The current version does not support selections for GetDominantColor(), but you can email me for an updated method that does.

Nigel
Xequte Software
www.imageen.com
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: