# Conversion_Morfology

## Using of command

Command aplied morfological operation to source image. Follow morfological operations are supported:

1. Erode :The function erodes the source image using the specified structuring element that determines the shape of a pixel neighborhood over which the minimum is taken:
   min src(x+x_a,y+y_a)
   where x_a,y_a are dimensions in element
   Erosion can be applied several (iterations) times. For color images, each channel is processed independently.
2. Dilate:The function dilates the source image using the specified structuring element that determines the shape of a pixel neighborhood over which the maximum is taken:
   max src(x+x_a,y+y_a)
   where x_a,y_a are dimensions in element
   Dilation can be applied several (iterations) times. For color images, each channel is processed independently.
3. Opening:Function combine Erode and Dilate operation according formula:
   dst=open(src,element)=dilate(erode(src,element),element)
4. Closing:Function combine Erode and Dilate operation according formula:
   dst=close(src,element)=erode(dilate(src,element),element)
5. Morfological gradient:Function combine Erode and Dilate operation according formula:
   dst=morph_ grad(src,element)=dilate(src,element)-erode(src,element)
6. Top hat:Function use formula:
   dst=tophat(src,element)=src-open(src,element)
7. Black hat:Function use formula:
   dst=blackhat(src,element)=close(src,element)-src

## Commands parameters

Command has 5 parameters:

1. Source picture: You need select source picture.Source picture must be activated before use of this function. You can select Picture_0 to Picture_19.
2. Destination picture: You need select destination picture. Destination picture must be activated before use of this function. Source and destination picture can be same. You can select Picture_0 to Picture_19.
3. Morfology type: You can selec one of morfological operation.
4. Iteration: You can set number of iteration.
5. Element shape:You need select shape of structuring element:
   1. RECT:A rectangular element
   2. ELLIPSE:an elliptic element
   3. CROSS:a cross-shaped element
6. Element width: you can set element width as number in pixels
7. Element height: you can set element height as a number in pixels
8. Anchor x:You need set relative horizontal offset of the anchor point
9. Anchor y: You need set relative vertical offset of the anchor point

## Error codes

1. Error code -11: Bad position of source picture in picture array. Error means that source picture is not in range 0 to 19. Check test program file if command has proper format.
2. Error code -12:Bad position of destination picture in picture array.Error means than destination picture is not in range 0 to 19.Check test program file if command has proper format.
3. Error code -13:Bad morfology type.Check test program file if command has proper format.
4. Error code -14: Bad iteration number. Iteration number must be more or equal than 1.
5. Error code -15: Bad element shape.Check test program file if command has proper format.
6. Error code -16:Bad elementh width. Element width must be more or equal than 1.
7. Error code -17:Bad element height. Element height must be more or equal than 1.
8. Error code -100: OpenCV error. Explanation of this error will be displayed in result window.