# Conversion_AdaptiveThreshold

## Using of command

Command is use for apply treshold value to selected image.Threshold is calculated individually for each pixel according adaptive method. Adaptive method is explained in command parameters. Source picture must be grayscale.Destination pixture is binary.

## Commands parameters

Command has 8 parameters:

1. Source picture: You need select source picture.Source picture must be single channel and must be activated before use of this function. You can select Picture_0 to Picture_19.
2. Destination picture:You need select destination picture where result of threshold function will be stored.Destination picture must be single channel and must be activated before use of this function.Dimension of destination picture (width, height) must be same as in source picture.You can select Picture_0 to Picture_19. Destination picture can be same as source picture
3. Adaptive method:You need select adaptive threshold algoritm.
   1. ADAPTIVE_THRESH_MEAN_C: Threshold value T(x,y) is calculated:
      T(x,y) is the mean of blockSize x blockSize neighborhood of (x, y) , minus C constant
   2. ADAPTIVE_THRESH_GAUSSIAN_C: Threshold value T(x,y) is calculated:
      T(x,y) is the weighted sum (i.e. cross-correlation with a Gaussian window) of of blockSize x blockSize neighborhood of (x, y) , minus C constant
4. Threshold type: You need select threshold type:
   1. THRESH_BINARY: destination pixels dest(x,y) are calculated:
      if(src(x,y)>T(x,y)) dest(x,y)=255
      else dest(x,y)=0
   2. THRESH_BINARY_INV: destination pixels dest(x,y) are calculated:
      if(src(x,y)>T(x,y)) dest(x,y)=0
      else dest(x,y)=255
5. Block size from: You can select from where you will read block size number. You can select Variable_0 to Variable_99 (in this case Block size number will be read from selected variable) or Number. If you select option "Number" you will select Block size number in the next parameter.
6. Block size number: This parameter is active only when you select onption "Number" in previous command. You can set Block size number to this line
7. C constant from: You can select from where you will read C constant number. You can select Variable_0 to Variable_99 (in this case C constant number will be read from selected variable) or Number. If you select option "Number" you will select C constant number in the next parameter.
8. C constant number: This parameter is active only when you select onption "Number" in previous command.You can set C constant number to this line.

## Error codes

1. Error code -11: Bad position in variable array in block size or c constant value variable. Error means that variable for BlockSize number or c constant is not from range 0 to 99. Check command format in test program file.
2. Error code -12:Bad position of source picture in picture array.Error means that source picture is not from range 0 to 19. Check command format in test program file.
3. Error code -13:Bad position of destination picture in picture array. Error means that destination picture is not from range 0 to 19. Check command format in the test program file.
4. Error code -14:Source image is not alocated. Source image must be alocated before this command.
5. Error code -15:Destination image is not alocated. Destination image must be alocated before this command.
6. Error code -16:Bad channel number in source image. Source image must be single channel.
7. Error code -17: Bad channel number in destination image.DEstination image must be single channel.
8. Error code -100: OpenCV error. Explanation of this error will be displayed in result window.OpenCV error is reported also when width or height of source or destination picture are not same.