Edge detection lazarus / 39-Graphics ---------------------------------------------------------------------- liewald · 2019-01-27 12:04 Anyone know of a lazarus based working sobel filter to work on either a tbitmap or a tbitmap32 thanks in advance ---------------------------------------------------------------------- engkin · 2019-01-27 16:31 For TImage32, check unit G32_WConvolution: Quote     *   28_02_2003 added procedure DoSobel( Dst, Src: TBitmap32);       * ---------------------------------------------------------------------- liewald · 2019-01-27 16:47 Sorry but I cant find that unit anywhere in graphics32 ---------------------------------------------------------------------- engkin · 2019-01-27 17:04 Attached. ---------------------------------------------------------------------- liewald · 2019-01-27 17:29 Sorry seems to be incompatible with newer Graphics32. Fixed an asm call but it seems that redcomponent etc have changed to a tcolor32  from a tcolor32array and it's killing it and because I dont know the algorithm I haven' t got a clue where to start a fix Compile Project, Target: Imgover.exe: Exit code 1, Errors: 50, Hints: 48 g32_wconvolution.pas(216,31) Error: Incompatible type for arg no. 1: Got "TColor32Array", expected "TColor32" GR32.pas(1265,10) Hint: Found declaration: RedComponent(TColor32):LongInt; g32_wconvolution.pas(216,61) Error: Incompatible type for arg no. 1: Got "TColor32Array", expected "TColor32" GR32.pas(1265,10) Hint: Found declaration: RedComponent(TColor32):LongInt; g32_wconvolution.pas(216,93) Error: Incompatible type for arg no. 1: Got "TColor32Array", expected "TColor32" GR32.pas(1265,10) Hint: Found declaration: RedComponent(TColor32):LongInt; g32_wconvolution.pas(217,31) Error: Incompatible type for arg no. 1: Got "TColor32Array", expected "TColor32" GR32.pas(1265,10) Hint: Found declaration: RedComponent(TColor32):LongInt; g32_wconvolution.pas(217,61) Error: Incompatible type for arg no. 1: Got "TColor32Array", expected "TColor32" GR32.pas(1265,10) Hint: Found declaration: RedComponent(TColor32):LongInt; g32_wconvolution.pas(217,93) Error: Incompatible type for arg no. 1: Got "TColor32Array", expected "TColor32" GR32.pas(1265,10) Hint: Found declaration: RedComponent(TColor32):LongInt; g32_wconvolution.pas(218,31) Error: Incompatible type for arg no. 1: Got "TColor32Array", expected "TColor32" GR32.pas(1265,10) Hint: Found declaration: RedComponent(TColor32):LongInt; g32_wconvolution.pas(218,61) Error: Incompatible type for arg no. 1: Got "TColor32Array", expected "TColor32" GR32.pas(1265,10) Hint: Found declaration: RedComponent(TColor32):LongInt; g32_wconvolution.pas(218,93) Error: Incompatible type for arg no. 1: Got "TColor32Array", expected "TColor32" GR32.pas(1265,10) Hint: Found declaration: RedComponent(TColor32):LongInt; g32_wconvolution.pas(223,33) Error: Incompatible type for arg no. 1: Got "TColor32Array", expected "TColor32" GR32.pas(1270,10) Hint: Found declaration: GreenComponent(TColor32):LongInt; g32_wconvolution.pas(223,65) Error: Incompatible type for arg no. 1: Got "TColor32Array", expected "TColor32" GR32.pas(1270,10) Hint: Found declaration: GreenComponent(TColor32):LongInt; g32_wconvolution.pas(223,99) Error: Incompatible type for arg no. 1: Got "TColor32Array", expected "TColor32" GR32.pas(1270,10) Hint: Found declaration: GreenComponent(TColor32):LongInt; g32_wconvolution.pas(224,33) Error: Incompatible type for arg no. 1: Got "TColor32Array", expected "TColor32" GR32.pas(1270,10) Hint: Found declaration: GreenComponent(TColor32):LongInt; g32_wconvolution.pas(224,65) Error: Incompatible type for arg no. 1: Got "TColor32Array", expected "TColor32" GR32.pas(1270,10) Hint: Found declaration: GreenComponent(TColor32):LongInt; g32_wconvolution.pas(224,99) Error: Incompatible type for arg no. 1: Got "TColor32Array", expected "TColor32" GR32.pas(1270,10) Hint: Found declaration: GreenComponent(TColor32):LongInt; g32_wconvolution.pas(225,33) Error: Incompatible type for arg no. 1: Got "TColor32Array", expected "TColor32" GR32.pas(1270,10) Hint: Found declaration: GreenComponent(TColor32):LongInt; g32_wconvolution.pas(225,65) Error: Incompatible type for arg no. 1: Got "TColor32Array", expected "TColor32" GR32.pas(1270,10) Hint: Found declaration: GreenComponent(TColor32):LongInt; g32_wconvolution.pas(225,99) Error: Incompatible type for arg no. 1: Got "TColor32Array", expected "TColor32" GR32.pas(1270,10) Hint: Found declaration: GreenComponent(TColor32):LongInt; g32_wconvolution.pas(230,32) Error: Incompatible type for arg no. 1: Got "TColor32Array", expected "TColor32" GR32.pas(1275,10) Hint: Found declaration: BlueComponent(TColor32):LongInt; g32_wconvolution.pas(230,63) Error: Incompatible type for arg no. 1: Got "TColor32Array", expected "TColor32" GR32.pas(1275,10) Hint: Found declaration: BlueComponent(TColor32):LongInt; g32_wconvolution.pas(230,96) Error: Incompatible type for arg no. 1: Got "TColor32Array", expected "TColor32" GR32.pas(1275,10) Hint: Found declaration: BlueComponent(TColor32):LongInt; g32_wconvolution.pas(231,32) Error: Incompatible type for arg no. 1: Got "TColor32Array", expected "TColor32" GR32.pas(1275,10) Hint: Found declaration: BlueComponent(TColor32):LongInt; g32_wconvolution.pas(231,63) Error: Incompatible type for arg no. 1: Got "TColor32Array", expected "TColor32" GR32.pas(1275,10) Hint: Found declaration: BlueComponent(TColor32):LongInt; g32_wconvolution.pas(231,96) Error: Incompatible type for arg no. 1: Got "TColor32Array", expected "TColor32" GR32.pas(1275,10) Hint: Found declaration: BlueComponent(TColor32):LongInt; g32_wconvolution.pas(232,32) Error: Incompatible type for arg no. 1: Got "TColor32Array", expected "TColor32" GR32.pas(1275,10) Hint: Found declaration: BlueComponent(TColor32):LongInt; g32_wconvolution.pas(232,63) Error: Incompatible type for arg no. 1: Got "TColor32Array", expected "TColor32" GR32.pas(1275,10) Hint: Found declaration: BlueComponent(TColor32):LongInt; g32_wconvolution.pas(232,96) Error: Incompatible type for arg no. 1: Got "TColor32Array", expected "TColor32" GR32.pas(1275,10) Hint: Found declaration: BlueComponent(TColor32):LongInt; g32_wconvolution.pas(235,13) Error: Incompatible types: got "TColor32" expected "TColor32Array" g32_wconvolution.pas(270,21) Error: Incompatible type for arg no. 1: Got "TColor32Array", expected "TColor32" GR32.pas(1265,10) Hint: Found declaration: RedComponent(TColor32):LongInt; g32_wconvolution.pas(270,52) Error: Incompatible type for arg no. 1: Got "TColor32Array", expected "TColor32" GR32.pas(1265,10) Hint: Found declaration: RedComponent(TColor32):LongInt; g32_wconvolution.pas(270,81) Error: Incompatible type for arg no. 1: Got "TColor32Array", expected "TColor32" GR32.pas(1265,10) Hint: Found declaration: RedComponent(TColor32):LongInt; g32_wconvolution.pas(270,112) Error: Incompatible type for arg no. 1: Got "TColor32Array", expected "TColor32" GR32.pas(1265,10) Hint: Found declaration: RedComponent(TColor32):LongInt; g32_wconvolution.pas(270,143) Error: Incompatible type for arg no. 1: Got "TColor32Array", expected "TColor32" GR32.pas(1265,10) Hint: Found declaration: RedComponent(TColor32):LongInt; g32_wconvolution.pas(271,21) Error: Incompatible type for arg no. 1: Got "TColor32Array", expected "TColor32" GR32.pas(1265,10) Hint: Found declaration: RedComponent(TColor32):LongInt; g32_wconvolution.pas(271,52) Error: Incompatible type for arg no. 1: Got "TColor32Array", expected "TColor32" GR32.pas(1265,10) Hint: Found declaration: RedComponent(TColor32):LongInt; g32_wconvolution.pas(271,81) Error: Incompatible type for arg no. 1: Got "TColor32Array", expected "TColor32" GR32.pas(1265,10) Hint: Found declaration: RedComponent(TColor32):LongInt; g32_wconvolution.pas(271,112) Error: Incompatible type for arg no. 1: Got "TColor32Array", expected "TColor32" GR32.pas(1265,10) Hint: Found declaration: RedComponent(TColor32):LongInt; g32_wconvolution.pas(271,143) Error: Incompatible type for arg no. 1: Got "TColor32Array", expected "TColor32" GR32.pas(1265,10) Hint: Found declaration: RedComponent(TColor32):LongInt; g32_wconvolution.pas(272,21) Error: Incompatible type for arg no. 1: Got "TColor32Array", expected "TColor32" GR32.pas(1265,10) Hint: Found declaration: RedComponent(TColor32):LongInt; g32_wconvolution.pas(272,52) Error: Incompatible type for arg no. 1: Got "TColor32Array", expected "TColor32" GR32.pas(1265,10) Hint: Found declaration: RedComponent(TColor32):LongInt; g32_wconvolution.pas(272,81) Error: Incompatible type for arg no. 1: Got "TColor32Array", expected "TColor32" GR32.pas(1265,10) Hint: Found declaration: RedComponent(TColor32):LongInt; g32_wconvolution.pas(272,112) Error: Incompatible type for arg no. 1: Got "TColor32Array", expected "TColor32" GR32.pas(1265,10) Hint: Found declaration: RedComponent(TColor32):LongInt; g32_wconvolution.pas(272,143) Error: Incompatible type for arg no. 1: Got "TColor32Array", expected "TColor32" GR32.pas(1265,10) Hint: Found declaration: RedComponent(TColor32):LongInt; g32_wconvolution.pas(273,21) Error: Incompatible type for arg no. 1: Got "TColor32Array", expected "TColor32" GR32.pas(1265,10) Hint: Found declaration: RedComponent(TColor32):LongInt; g32_wconvolution.pas(273,52) Error: Incompatible type for arg no. 1: Got "TColor32Array", expected "TColor32" GR32.pas(1265,10) Hint: Found declaration: RedComponent(TColor32):LongInt; g32_wconvolution.pas(273,81) Error: Incompatible type for arg no. 1: Got "TColor32Array", expected "TColor32" GR32.pas(1265,10) Hint: Found declaration: RedComponent(TColor32):LongInt; g32_wconvolution.pas(273,112) Error: Incompatible type for arg no. 1: Got "TColor32Array", expected "TColor32" GR32.pas(1265,10) Hint: Found declaration: RedComponent(TColor32):LongInt; g32_wconvolution.pas(273,143) Error: Incompatible type for arg no. 1: Got "TColor32Array", expected "TColor32" GR32.pas(1265,10) Hint: Found declaration: RedComponent(TColor32):LongInt; g32_wconvolution.pas(274,21) Error: Incompatible type for arg no. 1: Got "TColor32Array", expected "TColor32" GR32.pas(1265,10) Hint: Found declaration: RedComponent(TColor32):LongInt; g32_wconvolution.pas(274,52) Error: Incompatible type for arg no. 1: Got "TColor32Array", expected "TColor32" ---------------------------------------------------------------------- marcov · 2019-01-27 17:47 That looks horrible primitive, no SSE/AVX, and multipass(which hurts for large images, since then they are not cached) There are heaps of assembler versions. In my delphi software I use simd(lib), compiled into a DLL. (https://sourceforge.net/projects/simd/files/  there are versions on github also) I still planned to do sobel myself, but the relevant projects have been put on ice. (to save time for production I also usually only do 64-bit and aligned images) ---------------------------------------------------------------------- engkin · 2019-01-27 18:30 Guys, the file is from "28_02_2003". ---------------------------------------------------------------------- liewald · 2019-01-27 18:35 Yup.......... Loosing hair rapidly!!!!! ---------------------------------------------------------------------- liewald · 2019-01-28 14:36 Where there's a will there's a way Thanks all managed without graphics32 procedure TForm1.Button3Click(Sender: TObject); var bmp :  TBGRABitmap; begin      bmp:=TBGRABitmap.create(image.Picture.Bitmap);     bmp.assign(bmp.FilterContour);     image.Picture.Bitmap.Assign(bmp.Bitmap);     bmp.Free; end ---------------------------------------------------------------------- VTwin · 2019-01-28 19:29 I'm fairly sure TBGRABitmap.FilterContour is not identical to Sobel, but if it works for you that does not matter. ---------------------------------------------------------------------- liewald · 2019-01-29 09:38 Yup not the same but it achieves what I need would prefer sobel or canny but not worth the time or pain to develop I'm a lazy git at heart ---------------------------------------------------------------------- circular · 2019-01-29 15:56 Replace Code: Delphi  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i    bmp.assign(bmp.FilterContour);By Code: Delphi  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i    BGRAReplace(bmp, bmp.FilterContour);To avoid memory leak Note : FilterContour is not strictly speaking a Sobel filter but is also based on a 3x3 matrix. ---------------------------------------------------------------------- liewald · 2019-01-30 09:47 thanks