You'll find here https://towardsdatascience.com/understanding-morphological-image-processing-and-its-operations-7bcf1ed11756 a very clear explanation of morphological operators.
For Red, operators are defined in RedCV/libs/imgproc/rcvMorphology.red.
Rebol-OpenCV supports some basic morphological operators such as erode or dilate. Basically these operators are used with a binary image, but in reality they can be used with any image as illustrated in this code:
#!/usr/local/bin/r3
Rebol [
]
;--see https://docs.opencv.org/4.x/d4/d76/tutorial_js_morphological_ops.html
cv: import opencv ;--import Rebol-OpenCV extension
with cv [
src: imread "../../image/lena.png" ;--source image
namedWindow win1: "Source" ;--create window 1
namedWindow win2: "Erosion" ;--create window 2
namedWindow win3: "Dilatation" ;--create window 3
moveWindow win1 0x0 ;--move window 1
moveWindow win2 260x0 ;--move window 2
moveWindow win3 520x0 ;--move window 2
kernel1: getStructuringElement MORPH_CROSS 5 1 ;--prepare the kernel for erosion
kernel2: getStructuringElement MORPH_CROSS 5 -1 ;--prepare the kernel for dilatation
dst1: erode src none kernel1 -1x-1 1 ;--erode the source image
dst2: dilate src none kernel2 -1x-1 1 ;--dilate the source image
imshow/name src win1 ;--show the source image
imshow/name dst1 win2 ;--show the eroded image
imshow/name dst2 win3 ;--show the dilated image
waitKey 0 ;--any key to close
destroyAllWindows ;--delete all windows
]
Rebol [
]
;--see https://docs.opencv.org/4.x/d4/d76/tutorial_js_morphological_ops.html
cv: import opencv ;--import Rebol-OpenCV extension
with cv [
src: imread "../../image/lena.png" ;--source image
namedWindow win1: "Source" ;--create window 1
namedWindow win2: "Erosion" ;--create window 2
namedWindow win3: "Dilatation" ;--create window 3
moveWindow win1 0x0 ;--move window 1
moveWindow win2 260x0 ;--move window 2
moveWindow win3 520x0 ;--move window 2
kernel1: getStructuringElement MORPH_CROSS 5 1 ;--prepare the kernel for erosion
kernel2: getStructuringElement MORPH_CROSS 5 -1 ;--prepare the kernel for dilatation
dst1: erode src none kernel1 -1x-1 1 ;--erode the source image
dst2: dilate src none kernel2 -1x-1 1 ;--dilate the source image
imshow/name src win1 ;--show the source image
imshow/name dst1 win2 ;--show the eroded image
imshow/name dst2 win3 ;--show the dilated image
waitKey 0 ;--any key to close
destroyAllWindows ;--delete all windows
]
Aucun commentaire:
Enregistrer un commentaire