[OpenR8 solution] Image_FindBlob (Find objects in the image)
  1. Image_FindBlob

 

The purpose of this solution is to find objects in the image. The method is to extract the feature blob by means of the connected region representation, and then filter out the object further. The main flow of this method is shown in Fig. 1 below. An example diagram of an object found in the image is shown in Fig. 2 below.

 

Fig. 1. Flow chart..png

Fig. 1. Flow chart.

 

Fig. 2. Left.png

Fig. 2. Left: Original image. Right: Use this solution to find blob.

 

The solution folder contains three process files. The following chapters are described sequentially.

 

 

  1. FindBlob.flow

 

【Open R8.exe】=>【File】=>【Open】=>【Go to the solution/Image_FindBlob folder】=>【Click twice to load FindBlob.flow】. See Fig. 3 below.

 

Fig. 3. FindBlob.flow Diagram..jpg

Fig. 3. FindBlob.flow Diagram.

 

The process is from up to bottom:

【1 Image_Open】

Open the image you want to read. See Fig. 4 below. The way you select an image can be seen in Fig. 5 below.

 

Variable name

Name

value

use

imageFileName (String)

file name

sample.png

Read the image of the sample.png.

This variable is called file name.

If you want to change the image of another test. Change the value to the image path name you want to test.

image (Image)

SampleImage

 

Save the read-in image to this variable.

 

Fig. 4. Image opening of the process..png

Fig. 4. Image opening of the process.

 

Fig. 5. Image_Open - Select the file you want to read..png

Fig. 5. Image_Open - Select the file you want to read.

 

【2 Image_Show】

Show the images that are read in. See Fig. 6 below.

Variable name

name

value

use

image (Image)

SampleImage

 

Select the image variable you want to display.

displayPercentage (int)

 

 

Displays the percentage of the graph. A value of 200 means 200 (the picture size is magnified one times), 50 means 50 (the picture size is halved), and so on, zoom in and out.

windowTitle (string)

windowTitle

SampleImage

The title of the window that displays the image. The window name is SampleImage.

 

Fig. 6. Display the original image..png

Fig. 6. Display the original image.

 

【3 Image_Binarize】

Binarize the images that are read in. An image exceeds a certain value, and that place is shown in white. Conversely, less than a certain value, that place is shown in black.

See Fig. 7below. The value is higher than the white area will be smaller, the value is lowered, and the white area will become more.

Variable name

name

value

use

image (Image)

SampleImage

 

Select the image variable that you want to make binary. Sampleimage is the variable that is stored in the 1open_image of the process.

threshold (Int)

gray value

110

 

imageBinarize (Image)

Binarize Image

 

Save the image that finished binarization to a variable with the name Binarize image.

 

Fig. 7. Left.png

Fig. 7. Left : Original image. Right : binary image.

 

【4 Image_Show】

Display the results of image binarization. As shown in Fig. 7 (right) above.

Variable name

name

value

use

image (Image)

Binarize Image

 

Select the image variable you want to display. Binarize image is a variable that is stored after the binary of the image in Process 3.

displayPercentage (int)

 

 

Displays the percentage of the graph. A value of 200 means 200 (the picture size is magnified one times), 50 means 50 (the picture size is halved), and so on, zoom in and out.

windowTitle (string)

windowTitle

Binarize Image

The title of the window that displays the image. The window name is Binarize Image.

 

【5 Image_FindBlob】

Sets the image of the object you are looking for. Then set the conditions to find the object, such as: long, wide, area, etc.

Finally, the result message is stored in the Json variable, and the result image is stored to the variable of “imageTo”. See Fig. 8,Fig. 9 below.

Note: The previous step of this process is binarization, which can be replaced by other filtration methods to separate objects from the background.

Variable name

name

value

use

image (Image)

Binarize Image

 

Select the image variable you want to find the object. Enter an image that has finished binarization to find the object.

enableMin X (Bool)

 

 

 

min X (Int)

 

 

 

enableMax X (Bool)

 

 

 

max X (Int)

 

 

 

enableMin Y (Bool)

 

 

 

min Y (Int)

 

 

 

enableMax Y (Bool)

 

 

 

max Y (Int)

 

 

 

enableMinArea (Bool)

True

True

A switch that sets a minimum area threshold.

minArea (Int)

MinArea

1000

The minimum area threshold for the object found. This value is raised if the area of the object you are looking for is large. Conversely, the adjustment is small.

enableMaxArea (Bool)

 

 

 

maxArea (Bool)

 

 

 

enableMinFillRate (Bool)

 

 

 

minFillRate (Double)

 

 

 

enableMaxFillRate (Bool)

 

 

 

maxFillRate

(Double)

 

 

 

Json (Json)

Output Json

 

The result of the output to find out the area coordinates of the object in the image.

imageFrom (Image)

SampleImage

 

 

imageTo (Image)

Output Image

 

The variable is an image of the Output image. This image is drawn to find the result of the object.

type (String)

Type

Defect

The category name of the object being detected.

 

Fig. 8. Detected object messages..png

Fig. 8. Detected object messages.

 

Fig. 9. Find the result diagram of an object..png

Fig. 9. Find the result diagram of an object.

 

【6 Json_Print】

Displays the string message Json on the DOS window.

As shown in Fig. 8 above. Displays a result message looking for an object.

Variable name

Name

Value

Use

json (Json)

Output Json

 

Displays the result message output Json above [Image_FindBlob].

 

【7 Image_Show】

Displays the image as the result of looking for an object. As shown in Fig. 9 above.

Variable name

Name

Value

Use

image (Image)

Output Image

 

Select the image variable you want to display. The output Image is the result of looking for an object.

displayPercentage (int)

 

 

Displays the percentage of the graph. A value of 200 means 200 (the picture size is magnified one times), 50 means 50 (the picture size is halved), and so on, zoom in and out.

windowTitle (string)

windowTitle2

Output Image

The title of the window that displays the image. The window name is Output Image.

 

【8 Image_Save】

Stores a image of an object that has been found.

Variable name

Name

Value

Use

image (Image)

Output Image

 

The image variable to be stored.

imageFileName

(String)

Output File Name

output.png

The file name where the image is stored.

 

【9 WaitKey】

After the "image_show" must be added "Wait" to see the image, the image stay how many microseconds set.

Variable name

Name

Value

Use

keyCode (int)

keyCode

0

Parameters for output off.

milliSeconds (int)

milliSeconds

0

Set to 0 if you want the image display window to press any key to close; Set 1000 if you want the image display window to be turned off after 1 seconds. 1 seconds = 1000 microseconds.

 

【10 Image_DestoryAllWindows】

After "Image_show" and "Waitkey", be sure to add "Image_ DestoryAllWindows ".

This function closes all "Image_show" windows. See Fig. 10 below.

 

Fig. 10. Image_DestoryAllWindows..png

Fig. 10. Image_DestoryAllWindows.

 

 

  1. FindBlob_OnlyFindScrewCap.flow

 

The difference between this process and the second chapter Findblob.flow is as follows:

Image_FindBlob : Find coins and Screws

FindBlob_OnlyFindScrewCap : Did not find the coin, only find the screws.

The result is shown in Fig. 11Fig. 12.

 

Fig. 11. The result of Image_FindBlob..png

Fig. 11. The result of Image_FindBlob.

 

Fig. 12. The result of FindBlob_OnlyFindScrewCap..png

Fig. 12. The result of FindBlob_OnlyFindScrewCap.

 

The Find_imageblob and findblob_onlyfindscrewcap processes are different from "Image_FindBlob".

 

Its "Image_FindBlob" is different from the following table.  By setting different object size thresholds, you can filter out larger coins, leaving only the screws. 

Variable name

Find_ImageBlob

FindBlob_OnlyFindScrewCap

Use

image (Image)

Binarize Image

Binarize Image

Select the image variable you want to find the object. Enter an image that has finished binarization to find the object.

enableMin X (Bool)

 

 

 

min X (Int)

 

 

 

enableMax X (Bool)

 

 

 

max X (Int)

 

 

 

enableMin Y (Bool)

 

 

 

min Y (Int)

 

 

 

enableMax Y (Bool)

 

 

 

max Y (Int)

 

 

 

enableMinArea (Bool)

True

True

A switch that sets a minimum area threshold.

minArea (Int)

1000

1000

The minimum area threshold for the object found. This value is raised if the area of the object you are looking for is large. Conversely, the adjustment is small.

enableMaxArea (Bool)

True

 

A switch that sets the maximum area threshold.

maxArea (Bool)

5000

 

The maximum area threshold for the object found.

enableMinFillRate (Bool)

 

 

 

minFillRate (Double)

 

 

 

enableMaxFillRate (Bool)

 

 

 

maxFillRate

(Double)

 

 

 

Json (Json)

Output Json

Output Json

The result of the output to find out the area coordinates of the object in the image.

imageFrom (Image)

SampleImage

SampleImage

 

imageTo (Image)

Output Image

Output Image

The variable is an image of the Output image. This image is drawn to find the result of the object.

type (String)

Defect

Defect

The category name of the object being detected.

 

 

  1. FindBlobAndDrawRectJson.flow

 

This process file selects different object boxes to mark their names.

 

Mainly different from the above two processes than the use of two "Image_FindBlob". The coins (coin) and screws (CAP) are filtered out of the image with different area sizes, and the result messages of two “Image_ FindBlob” are integrated, and the message is finally drawn to the picture.

 

Fig. 13. The result of FindBlobAndDrawRectJson..png

Fig. 13. The result of FindBlobAndDrawRectJson.

 

The process content differences are shown in Figure 14 below. Described as follows:

【Image_FindBlob】Find coins and two screws

  1. Image_FindBlob

Limit to find the minimum object area Minarea is 1000.

  1. Displays an image that uses the “Image_FindBlob” output. 

 

 【FindBlob_OnlyFindScrewCap】Find the coin.

  1. Image_FindBlob:

Limit to find the minimum object area Minarea is 1000 and the maximum area Maxarea is 5000.

  1. Displays an image that uses the “Image_FindBlob” output. 

 

【FindBlobAndDrawRectJson】Find the coin with two screws and mark the box as the category name to which it belongs.

  1. Image_FindBlob:

Limit to find the minimum object area Minarea is 1000 and the maximum object area Maxarea is 5000.

  1. JsonArray_AppendNew

Merge the result messages of two "Image_FindBlob".

  1. Display with "Image_DrawRectJson " to draw a message to the image  (The above Minarea and Maxarea area units are  pixel2

 

Fig. 14. The flow chart of FindBlobAndDrawRectJson. Red Frame.png

Fig. 14. The flow chart of FindBlobAndDrawRectJson. Red Frame: The difference between the other two flow in this article.


Recommended Article

1.
OpenR8 Community Edition - AI Software for Everyone (Free Download)