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
83 Posts

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

xequte

38977 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
83 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

38977 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

xequte

38977 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: