Bixby Sayz Posted November 19, 2013 Share Posted November 19, 2013 Asked this on the other forums didn't much response. SCAR might even have some built-in functions I'm not aware of to do what I want. Got a TPointArray containing a series of points that define 2 overlapping boxes (see image). Need to find the 2 boxes. Quote Link to comment Share on other sites More sharing options...
FHannes Posted November 19, 2013 Share Posted November 19, 2013 SCAR doesn't have functions to handle this, if I understand you correctly. But it's also a fairly complex problem, considering you can divide up a cloud of points in any number of different boxes. Quote Link to comment Share on other sites More sharing options...
Bixby Sayz Posted November 19, 2013 Author Share Posted November 19, 2013 It's not as complex as it could be. There are some constraints: - 1 or 2 boxes max - If 2nd box is present left box is smaller, right box is larger. Got a couple things in mind. Just haven't had time to try it. Quote Link to comment Share on other sites More sharing options...
Wanted Posted November 20, 2013 Share Posted November 20, 2013 GetTPABounds compare bounds via maths i.e. BoxContaints, TBAContains, <=, etc. etc. https://github.com/OSI1/OfficialSCARInclude/tree/master/Divi/TFunctions https://github.com/OSI1/OfficialSCARInclude/blob/master/Divi/TFunctions/Box.scar https://github.com/OSI1/OfficialSCARInclude/blob/master/Divi/TFunctions/TBA.scar https://github.com/OSI1/OfficialSCARInclude/blob/master/Divi/TFunctions/Integer.scar What are you doing on those other forums? Comon bro, lols. I see you got promoted to VIP Quote Link to comment Share on other sites More sharing options...
slacky Posted November 20, 2013 Share Posted November 20, 2013 (edited) If SCARExt is an option to use, then this function will work on your image, it will extract the two boxes you have there (but can do much more then just that). I took the liberty to modify your image, with additional shapes, and then separating am in to boxes as well with this function: The code I used: program New; {$I SCARExt/SCARExt.scar} var bmp:TSCARBitmap; function GetBitmapColorTPA(bmp: TSCARBitmap; Color, Tol: Integer): TPointArray; var client: TSCARClient; begin client := SetClient(TSCARBitmapClient.Create(bmp)); FindColorTolEx(Result, Color, 0, 0, (bmp.Width - 1), (bmp.Height - 1),Tol); SetClient(client).Free; end; function TPAFindBoxes(TPA:TPointArray): TBoxArray; var i: Integer; ATPA:T2DPointArray; begin TPA := XT_UniteTPA(XT_InvertTPA(TPA), XT_TPABorder(TPA), False); ATPA := XT_ClusterTPA(TPA,1,False); SetLength(Result, High(ATPA)); for i:=1 to High(ATPA) do begin Result[i-1] := TPABounds(ATPA[i]); ExpandBox(Result[i-1], 1); end; end; var TPA:TPointArray; i:Integer; TBA: TBoxArray; begin Bmp := TSCARBitmap.Create('deNrt3FFuHEkOBFDrwr6jT9b+NQSo0WZmspLke' + 'wfYsaIiqKrBjv98/f76BQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHClF/AD94F' + 'PTqgQwDTQEzAN9ARMAz0B00BPwDRAT8A00BMwDfQETAM9AdNATwDTQE/ANNATM' + 'A30BEwDPQHTAD0B00BPwDTQEzAN9ARMAz0BTAM9AdNAT8A00BMwDfQETAP0BEw' + 'DPQHTQE/ANNATMA30BDAN9ARMAz0B00BPwDTQEzAN0BMwDfQETAM9AdNAT8A00' + 'BPANNATMA30BEwDPQHTQE/ANEBPwDTQEzAN9ARMAz0B00BPANNAT8A00BMwDfQ' + 'EanXSNNATinbyhlqaBnpC0ft5wxU1DfSEuoV8/IqaBnpC6UI+e0VNAz2h4lf8J' + 'f00DfSE6m188EXUNNATSr+CPntFTQM9oUcVH7mipoGe0KaK+VfUNNATqn/FP3h' + 'FTQM9oVkPnVCcUFg5oWmNNQ30hDZf8flX1DTQE1qWMOeKmgZ6QtcSJlxR00BPa' + 'PYVn3lFTQM9oXcDj15R00BP6PoKmlBg00BPaF+/cy+ipoGeMKF+h66oaaAn9P6' + 'KP3pFTQM9YU73tl9R00BPGNW9vVfUNNATJnzFH+qzaaAnTCve3n+/6jGhJ0wr3' + 'q4rahroCaO+4vf+75sGesLY1t383z2hzHDtK+iuf5BpoCcMr9zKFTUN9ASVc0J' + 'xQvEVn/9PNA30BH0LX1HTQE/Qt/AVNQ30hOFf8Sv/dNNAT1C28BU1DfQEZQv/G' + 'UwDPcFXfPiP0XUaL8ji7rX8Zf3hw218QrURTZPn6SvqhIKm+YoP/5GcUNA0YYa' + 'vqBMKmuYVNPyU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AAAAAAB/6CyEi5' + 'Q8='); TPA := GetBitmapColorTPA(bmp, clWhite, 1); TBA := TPAFindBoxes(TPA); //Display am for i:=0 to High(TBA) do begin TPA := [Point(TBA[i].x1, TBA[i].y1), Point(TBA[i].x2, TBA[i].y1), Point(TBA[i].x2, TBA[i].y2), Point(TBA[i].x1, TBA[i].y2)]; bmp.SetPixels(XT_ConnectTPA(TPA), Random($FFFFFF)); end; DebugBitmap(bmp); Bmp.Free; end. It can be done without SCARExt, using FloodFill on the generated bitmaps background (with a color that is not black), and then extracting each black pixel, and splitting. That will require you to also make the bitmap 1px larger in each side (ensure floodfill start-point, and that is get around your squares). Edit, written with pure SCAR, but this wont work as well, as SCARs FloodFill is eightway (so it seems), and doesn't allow us to set it to fourway, so the triangle in my example wont get extracted, it does leak... But it will work fine for your simple example (also not sure how SplitTPAEx acts in this case - Untested). function TPAFindBoxes(TPA:TPointArray): TBoxArray; var i: Integer; bmp:TSCARBitmap; B: TBox; ATPA:T2DPointArray; begin bmp := TSCARBitmap.Create(''); B := TPABounds(TPA); ExpandBox(B,1); bmp.SetSize(B.x2-B.x1+1, B.y2-B.y1+1); OffsetTPA(TPA, -B.x1, -B.y1); bmp.SetPixels(TPA, clRed); FloodFill(bmp,0,0,255); TPA := GetBitmapColorTPA(bmp, clBlack, 1); ATPA := SplitTPAEx(TPA,1,1); SetLength(Result, Length(ATPA)); for i:=0 to High(ATPA) do begin Result[i] := TPABounds(ATPA[i]); ExpandBox(Result[i],1); OffsetBox(Result[i], B.x1, B.y1); end; Bmp.Free; end; Edited November 20, 2013 by slacky Fixed the function (found a bug). Quote Link to comment Share on other sites More sharing options...
Janilabo Posted November 20, 2013 Share Posted November 20, 2013 If SCARExt is an option to use, then this function will work on your image, it will extract the two boxes you have there (but can do much more then just that). I took the liberty to modify your image, with additional shapes, and then separating am in to boxes as well with this function: The code I used: program New; {$I SCARExt/SCARExt.scar} var bmp:TSCARBitmap; function GetBitmapColorTPA(bmp: TSCARBitmap; Color, Tol: Integer): TPointArray; var client: TSCARClient; begin client := SetClient(TSCARBitmapClient.Create(bmp)); FindColorTolEx(Result, Color, 0, 0, (bmp.Width - 1), (bmp.Height - 1),Tol); SetClient(client).Free; end; function TPAFindBoxes(TPA:TPointArray): TBoxArray; var i: Integer; bmp:TSCARBitmap; B: TBox; ATPA:T2DPointArray; begin bmp := TSCARBitmap.Create(''); B := TPABounds(TPA); bmp.SetSize(B.x2 - B.x1 + 1, B.y2 - B.y1 + 1); OffsetTPA(TPA, -B.x1, -B.y1); bmp.SetPixels(XT_FloodFillPolygon(TPA, True), clBlue); bmp.SetPixels(TPA, clRed); TPA := GetBitmapColorTPA(bmp, clBlue, 1); ATPA := XT_ClusterTPA(TPA,1,False); SetLength(Result, Length(ATPA)); for i:=0 to High(ATPA) do begin Result[i] := TPABounds(ATPA[i]); ExpandBox(Result[i],1); OffsetBox(Result[i], B.x1, B.y1); end; Bmp.Free; end; var TPA:TPointArray; i:Integer; TBA: TBoxArray; begin Bmp := TSCARBitmap.Create('deNrt3FFuHEkOBFDrwr6jT9b+NQSo0WZmspLke' + 'wfYsaIiqKrBjv98/f76BQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHClF/AD94F' + 'PTqgQwDTQEzAN9ARMAz0B00BPwDRAT8A00BMwDfQETAM9AdNATwDTQE/ANNATM' + 'A30BEwDPQHTAD0B00BPwDTQEzAN9ARMAz0BTAM9AdNAT8A00BMwDfQETAP0BEw' + 'DPQHTQE/ANNATMA30BDAN9ARMAz0B00BPwDTQEzAN0BMwDfQETAM9AdNAT8A00' + 'BPANNATMA30BEwDPQHTQE/ANEBPwDTQEzAN9ARMAz0B00BPANNAT8A00BMwDfQ' + 'EanXSNNATinbyhlqaBnpC0ft5wxU1DfSEuoV8/IqaBnpC6UI+e0VNAz2h4lf8J' + 'f00DfSE6m188EXUNNATSr+CPntFTQM9oUcVH7mipoGe0KaK+VfUNNATqn/FP3h' + 'FTQM9oVkPnVCcUFg5oWmNNQ30hDZf8flX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lwzjxLyp2F3TijYo905oS/gB06oEwoYu1QBY0eqgLFLFTB2qQLG3ilVwYKl43c' + 'TYOayBczcGz5g4xIGrBvv+WDa+FUF2LW0AYuWOWDLSB6sGPkD9nvPU/AgwGzx6' + 'wysFc8FsFNfB4B5elKASeKpgRmS/wTlANaH34NgdHimYGiUfr4eMVgWfleCKeH' + 'pg/ngGwTsBd3QDbAOtAVsAf0BzUejQM/RMR1Dq2Fj6xQPBQZtRFFBS0Eh6ddeB' + 'UbrwPsAqgVeFdAf6LoIo0A9wGrw6OHaZRmXZwps36AZekzAic2arcyBQ0s3dtE' + 'B565Es6Mx7ecF6t6fO3mOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAB/6CyEi5' + 'Q8='); TPA := GetBitmapColorTPA(bmp, clWhite, 1); TBA := TPAFindBoxes(TPA); //Display am for i:=0 to High(TBA) do begin TPA := [Point(TBA[i].x1, TBA[i].y1), Point(TBA[i].x2, TBA[i].y1), Point(TBA[i].x2, TBA[i].y2), Point(TBA[i].x1, TBA[i].y2)]; bmp.SetPixels(XT_ConnectTPA(TPA), Random($FFFFFF)); end; DebugBitmap(bmp); Bmp.Free; end. It can be done without SCARExt, using FloodFill on the generated bitmaps background (with a color that is not black), and then extracting each black pixel, and splitting. That will requres you to also make the bitmap 1px larger in each side (ensure floodfill start-point, and that is get around your squares). Edit, written with pure SCAR, but this wont work as well, as SCARs FloodFill is eightway, and doesnt allow us to set it to fourway, so the triangle in my example wont get extracted, cuz it will leak... But it will work fine for your simple example. function TPAFindBoxes(TPA:TPointArray): TBoxArray; var i: Integer; bmp:TSCARBitmap; B: TBox; ATPA:T2DPointArray; begin bmp := TSCARBitmap.Create(''); B := TPABounds(TPA); ExpandBox(B,1); bmp.SetSize(B.x2-B.x1+1, B.y2-B.y1+1); OffsetTPA(TPA, -B.x1, -B.y1); bmp.SetPixels(TPA, clRed); FloodFill(bmp,0,0,255); TPA := GetBitmapColorTPA(bmp, clBlack, 1); ATPA := SplitTPAEx(TPA,1,1); SetLength(Result, Length(ATPA)); for i:=0 to High(ATPA) do begin Result[i] := TPABounds(ATPA[i]); ExpandBox(Result[i],1); OffsetBox(Result[i], B.x1, B.y1); end; Bmp.Free; end; slacky for the rescue! Very interesting solution mate, which works like charm. I don't see why it would be any problem to have SCARExt as an option.. Quote Link to comment Share on other sites More sharing options...
Wanted Posted November 20, 2013 Share Posted November 20, 2013 Wow nice work Slacky! Quote Link to comment Share on other sites More sharing options...
Bixby Sayz Posted November 20, 2013 Author Share Posted November 20, 2013 (edited) Nice!!! I'll have a look at this later after I have time to digest it. Edit: GetBitmapColorTPA ??? Edit2: Nvm CurClient := SetClient(TSCARBitmapClient.Create(Bmp)); with GetClient.ImageArea do FindColorEx(Tpa, clBlack, X1, Y1, X2, Y2); SetClient(CurClient).Free(); Found a version of GetBitmapColorTPA by Janilabo on PasteBin but it only took 2 params, not 3. Not sure what that 3rd param is supposed to be. http://pastebin.com/bjtkReJn Edited November 20, 2013 by Bixby Sayz Quote Link to comment Share on other sites More sharing options...
Janilabo Posted November 20, 2013 Share Posted November 20, 2013 (edited) Nice!!! I'll have a look at this later after I have time to digest it. Edit: GetBitmapColorTPA ??? Edit2: Nvm CurClient := SetClient(TSCARBitmapClient.Create(Bmp)); with GetClient.ImageArea do FindColorEx(Tpa, clBlack, X1, Y1, X2, Y2); SetClient(CurClient).Free(); Found a version of GetBitmapColorTPA by Janilabo on PasteBin but it only took 2 params, not 3. Not sure what that 3rd param is supposed to be. [Pascal] {$loadlib pumbaa.dll} const DIST = 7.5; function GetBitmapColorTPA(bmp: - Pastebin.com slacky added support for tolerance to hes version.So, the 3rd parameter (Tol) is tolerance, that way it can collect pixels with similar colors aswell. That one by me in pastebin is Simba-based, so it wont work with SCAR. SCAR version with 2 parameters would be: function GetBitmapColorTPA(bmp: TSCARBitmap; color: Integer): TPointArray; var client: TSCARClient; begin client := SetClient(TSCARBitmapClient.Create(bmp)); FindColorEx(Result, color, 0, 0, (bmp.Width - 1), (bmp.Height - 1)); SetClient(client).Free; end; Edited November 20, 2013 by Janilabo Quote Link to comment Share on other sites More sharing options...
slacky Posted November 21, 2013 Share Posted November 21, 2013 (edited) Nice!!! I'll have a look at this later after I have time to digest it. Edit: GetBitmapColorTPA ??? Edit2: Nvm CurClient := SetClient(TSCARBitmapClient.Create(Bmp)); with GetClient.ImageArea do FindColorEx(Tpa, clBlack, X1, Y1, X2, Y2); SetClient(CurClient).Free(); Found a version of GetBitmapColorTPA by Janilabo on PasteBin but it only took 2 params, not 3. Not sure what that 3rd param is supposed to be. [Pascal] {$loadlib pumbaa.dll} const DIST = 7.5; function GetBitmapColorTPA(bmp: - Pastebin.com There is no need to use "GetBitmapColorTPA", it was simply added for the sake of the example... All you need is the function "TPAFindBoxes", and to give the function the TPA that you gathered. Edited November 21, 2013 by slacky Quote Link to comment Share on other sites More sharing options...
Bixby Sayz Posted November 21, 2013 Author Share Posted November 21, 2013 Works like a treat with a few caveats. If there are any extra pixels scattered around you get a gazillion boxes. Can work around this with a bit of filtering. More serious I've noticed that the boxes can sometimes have small gaps of a couple pixels in them. This only works if the boxes are solid with no gaps. I'll have to approach this a different way and give up on the boxes. Or simply give up on it. This is a 1/50 chance special case (maybe less). The world won't end if not handled those few times. Quote Link to comment Share on other sites More sharing options...