# Coversion_MaskPicture

## Using of command

This command is used for create new picture which can be used as a mask picture. It means that can be computed with other image to mask some parts of image. Function create new image (color or grayscale) and mask objects (color or grayscale) on this image. Function has edit window which will be executed in debug mode one step run. Edit window display image also with other image which we want to mask.

## Commands parameters

Command has 13 parameters:

1. Mask picture: Select picture where will be stored new image
2. Type of picture:It can be select type of image :
   1. Binary: In this option image will be grayscale with binary values 0 or 255. One is for background, the second one is for foreground
   2. Color: This option create color image where bacground and foreground will be collor
3. Use clone picture: If this option is selected new picture width and height will be cloned from existing image (Select this image in the next step). If this option is not selected width and height will be selected in other options
4. Clone picture. This option select which image parameter will be cloned to new on. It must be selected option 'Use clone picture' in previous step. This picture must be loaded before this command
5. Background color type: It can be select type of backgroung color. Black,White,Color
6. Background color: Click on this line , color dialog will be open. Select color of background if option Color was selected in previous line
7. Mask color type: It can be select type of foreground color. Black,White,Color
8. Mask color: Click on this line , color dialog will be open. Select color of foreground (Mask) if option Color was selected in previous line
9. Mask picture width: Mask picture width if Clone picture option was not set in previous line
10. Mask picture height: Mask picture height if Clone picture option was not set in previous line
11. X-offset: It can be select ofset in X-axis which can be stored in some variable. This offset will be add to X-axis value on each mask element. It can be used if we need dynamically move mask on the picture
12. Y-offset :It can be select ofset in Y-axis which can be stored in some variable. This offset will be add to Y-axis value on each mask element. It can be used if we need dynamically move mask on the picture
13. Mask objects: This option will be add automatically from edit window. It can be select also manually for each element of mask. Command consinst from element description and aditional parameters. Ech elements are separated with ';' Elements type:
    1. P= Polynome: -> point 1 X, point1 Y, ':'-separator -> point 2 X, point 2 Y and so on. Example P:187 25:178 149:183 150
    2. C- Circle : -> Center X , Center Y, ':'-separator ->radius 0. Example:C:100 41:52 0
    3. R-Rectangle: ->Point 1X Point 1Y':'-separator->Point 2X Point 2Y':'-separator ->Point 3X Point 3Y':'-separator ->Point 4X Point 4Y . Example: R:227 118:227 143:274 143:274 118

## Edit window

Edit window is activated in debug mode when is set break on Conversion_MaskPicture line and Run one step is activated
If Clone picture option was selected cloned image will be displayed with background of new image. Slider in 'Type' window mixed this two images

1. Picture window: It is in the top part of page and display cloned image and mask image mixed according slider setup. Left click on mouse button start draw selected object on area. release of left button stop drawing object
2. Command window: It is in the left bottom part of window. Display all elements command.Right click on selected command can clone new element from element where is placed cursor
3. Type window: It is in the bottom part of window. It can be select type of element (rectangle,circle,polynome). Slider mixed cloned image and new image
   1. Rectangle: Left click on area where you want to drive rectangle and move cursor. Release left mouse button for stop drawing. Click on button New for add rectangle to the element list
   2. Circle:Left click on area with circle center. Move mouse and release left button for stop drawing. Click button New for add circle to the element list
   3. Polynom: Left click on the start poit, release left button, move mouse, left click on other point. Click new and selected polynom will be add to the element list.
4. New button: Add element to element list
5. Delete button: Remove selected elemnt from element command list

## Error codes

1. Error code -11:Bad position in float aray. Not in range (0..99)
2. Error code -12:Bad circle vector size
3. Error code -13:Bad mask picture position. It must be from range (0..19).
4. Error code -14:Bad clone picture position.It must be from range (0..19)
5. Error code -100:OpenCV error.