ImageEn, unit imageenproc

Analysis Method Testing


Testing of Analysis Methods


These images were generated using the demo:
\Demos\InputOutput\EveryMethod\EveryMethod.dpr

All Test Results
- Analysis Methods
- Color Adjustment Methods
- Color Depth Methods
- Alpha and Painting Methods
- Effects Methods
- Geometric Methods
- Filter Methods
- Smoothing Methods
- Other Methods


// Load test image
ImageEnView1.IO.LoadFromFile( 'D:\TestImage.jpg' );

  


 CalcAverageRGB

// Return the average RGB values of the selection (with sample size of 100)
rgb := ImageEnView1.Proc.CalcAverageRGB( 100 );
s := format( 'Average RGB: %d, %d, %d', [ rgb.r, rgb.g, rgb.b ]);

ImageTest1.jpg: Average RGB: 138, 106, 86
ImageTest2.jpg: Average RGB: 245, 218, 144
ImageTest3.jpg: Average RGB: 102, 91, 82


 CalcImageNumColors

// Return the number of colors found in the image
n := ImageEnView1.Proc.CalcImageNumColors();
s := format( 'Color count: %d', [ n ]);

ImageTest1.jpg: Color count: 62008
ImageTest2.jpg: Color count: 15910
ImageTest3.jpg: Color count: 21283


 CalcImageTransparency

// Return the percentage of pixels that are partially or fully transparent
ImageEnView1.Proc.SetTransparentColors( CreateRGB(192, 192, 192), CreateRGB(255, 255, 255), 0 ); // Make colors similar to white transparent
d := ImageEnView1.Proc.CalcImageTransparency();
s := format( 'Image Transparency: %d%%', [ Round( d * 100 )]);

  

ImageTest1.jpg: Image Transparency: 2%
ImageTest2.jpg: Image Transparency: 45%
ImageTest3.jpg: Image Transparency: 9%


 CalcStdDev

// Return the Standard Deviation of the image
d := ImageEnView1.Proc.CalcStdDev();
s := 'Standard Deviation: ' + FloatToStr( d );

ImageTest1.jpg: Standard Deviation: 59.55442
ImageTest2.jpg: Standard Deviation: 66.16412
ImageTest3.jpg: Standard Deviation: 78.59620


 GetDominantColor

// Return the most common color in the image (and its percentage of the image)
d := ImageEnView1.Proc.GetDominantColor( rgb );
s := format( 'Dominant Color (%d%%): %s', [ Round( d ), ColorToHex( TRGB2TColor( rgb )) ]);

ImageTest1.jpg: Dominant Color (0%): #060606
ImageTest2.jpg: Dominant Color (39%): #FFFFFF
ImageTest3.jpg: Dominant Color (20%): #1C1C1C


 GetCMYKChannels

// Return the Cyan channel of the image
bmp1 := ImageEnView1.Proc.GetCMYKChannels( 0 );

  

// Return the Magenta channel of the image
bmp1 := ImageEnView1.Proc.GetCMYKChannels( 1 );

  

// Return the Yellow channel of the image
bmp1 := ImageEnView1.Proc.GetCMYKChannels( 2 );

  

// Return the Key (black) channel of the image
bmp1 := ImageEnView1.Proc.GetCMYKChannels( 3 );

  


 GetHSVChannel

// Return the Hue channel of the image
bmp1 := ImageEnView1.Proc.GetHSVChannel( 0 );

  

// Return the Saturation channel of the image
bmp1 := ImageEnView1.Proc.GetHSVChannel( 1 );

  

// Return the Value channel of the image
bmp1 := ImageEnView1.Proc.GetHSVChannel( 2 );

  


 GetRGBChannel

// Return the Red channel of the image
bmp1 := ImageEnView1.Proc.GetRGBChannel( iecRed );

  

// Return the Green channel of the image
bmp1 := ImageEnView1.Proc.GetRGBChannel( iecGreen );

  

// Return the Blue channel of the image
bmp1 := ImageEnView1.Proc.GetRGBChannel( iecBlue );

  


 SeparateObjects

// Show detected objects in the image
ImageEnView1.Proc.SaveUndo();
ImageEnView1.Proc.ConvertToBWThreshold( 80 ); // Better detection
rects := ImageEnView1.Proc.SeparateObjects( 4, True, 10 );
ImageEnView1.Proc.Undo(); // Get full color image back
ImageEnView1.IEBitmap.IECanvas.DrawRects( rects, clRed, 2 );
// Output object count
ImageEnView1.Proc.TextOut( Align_Text_Near_Left, Align_Text_Near_Top, Format( 'Objects: %d', [ rects.Count ]), 'Arial', 10, clRed, [fsBold] );
ImageEnView1.Update;
rects.free;

 




 createBlobDetector (IEVision)

// Detect blobs/shapes in image
detector := IEVisionLib().createBlobDetector();
detector.setFilterByInertia( False, 0.1, 3.4e+38 );
detector.setFilterByConvexity( False, 0.95, 3.4e+38 );
keyPoints := detector.detect( ImageEnView1.IEBitmap.GetIEVisionImage() );
ImageEnView1.IEBitmap.IECanvas.DrawRects( keyPoints, clRed, 2, True );
ImageEnView1.Proc.TextOut( Align_Text_Near_Left, Align_Text_Near_Top, Format( 'Found: %d', [ KeyPoints.size ]), 'Arial', 12, Text_Color, [fsBold] );
ImageEnView1.Update();

 


 detectLines (IEVision)

// Load test image
ImageEnView1.IO.LoadFromFile( 'D:\TestImage.jpg' );

   

// Detects lines using a Binary Descriptor
lines := ImageEnView1.IEBitmap.GetIEVisionImage().detectLines( ievBinaryDescriptor );
ImageEnView1.IEBitmap.IECanvas.DrawLines( lines, clRed, 2 );
ImageEnView1.Proc.TextOut( Align_Text_Near_Left, Align_Text_Near_Top, Format( 'Lines: %d', [ lines.size ]), 'Arial', 12, Text_Color, [fsBold] );
ImageEnView1.Update();

   

// Detects lines using a LSD Detector
lines := ImageEnView1.IEBitmap.GetIEVisionImage().detectLines( ievLSDDetector );
ImageEnView1.IEBitmap.IECanvas.DrawLines( lines, clRed, 2 );
ImageEnView1.Proc.TextOut( Align_Text_Near_Left, Align_Text_Near_Top, Format( 'Lines: %d', [ lines.size ]), 'Arial', 12, Text_Color, [fsBold] );
ImageEnView1.Update();

   


 houghLinesP (IEVision)

// Load test image
ImageEnView1.IO.LoadFromFile( 'D:\TestImage.jpg' );

   

// Finds line segments in a binary image using the probabilistic Hough transform
ImageEnView1.Proc.SaveUndo();
ImageEnView1.IEBitmap.PixelFormat := ie8g;
ImageEnView1.IEBitmap.GetIEVisionImage().blur( IEVisionSize(3, 3), IEVisionPoint(-1, -1) );
ImageEnView1.IEBitmap.GetIEVisionImage().canny( 50, 200, 3 );
lines := ImageEnView1.IEBitmap.GetIEVisionImage().houghLinesP( 1, PI / 180, 200, 100, 10 );
ImageEnView1.Proc.Undo(); // Restore full color image
ImageEnView1.IEBitmap.IECanvas.DrawLines( lines, clRed, 2 );
ImageEnView1.Proc.TextOut( Align_Text_Near_Left, Align_Text_Near_Top, Format( 'Lines: %d', [ lines.size ]), 'Arial', 12, Text_Color, [fsBold] );
ImageEnView1.Update();

   


 findIn (IEVision)

// Find Faces in image
objectsFinder := IEVisionLib.createObjectsFinder();
objectsFinder.addClassifier('face detector 1', IEVisionLib.createCascadeClassifier(IEVC_FRONTAL_FACE_DEFAULT));
objectsFinder.addClassifier('face detector 2', IEVisionLib.createCascadeClassifier(IEVC_FRONTAL_FACE_ALT_TREE));
objectsFinder.addClassifier('face detector 3', IEVisionLib.createCascadeClassifier(IEVC_FRONTAL_FACE_ALT));
objectsFinder.addClassifier('face detector 4', IEVisionLib.createCascadeClassifier(IEVC_FRONTAL_FACE_ALT_2));
objectsFinder.addClassifier('face detector 5', IEVisionLib.createCascadeClassifier(IEVC_PROFILE_FACE));
objectsFinder.findIn(ImageEnView1.IEBitmap.GetIEVisionImage());
rects := objectsFinder.mergeAllRects(); // merge intersecting rectangles
ImageEnView1.IEBitmap.IECanvas.DrawRects( rects, clRed, 2 );
ImageEnView1.Proc.TextOut( Align_Text_Near_Left, Align_Text_Near_Top, Format( 'Found: %d', [ rects.size ]), 'Arial', 12, Text_Color, [fsBold] );
ImageEnView1.Update();

  





See Also

- Analysis Methods
- Color Adjustment Methods
- Color Depth Methods
- Alpha and Painting Methods
- Effects Methods
- Geometric Methods
- Filter Methods
- Smoothing Methods
- Other Methods