1

I am new in image processing and opencv. I need to threshold my gray scale image. The image contains all value between 0 to 1350 and I want to keep all values which are more than 100. I found this function in opencv:

cv::threshold( Src1, Last, 100, max_BINARY_value,3);

I do not know what should I write in the max_BINARY_value part and aslo I do not know if the last item is selected correctly or not.

Thanks in advance.

user2758510
  • 159
  • 5
  • 20

1 Answers1

1

To use cv::threshold you use

C++: double threshold(InputArray src, OutputArray dst, double thresh, double maxval, int type)

You selected your Src1, Last and your Threshold 100correctly. maxval is only used if you use THRESH_BINARY or THRESH_BINARY_INV as type.

What you want to use is cv::THRESH_TOZERO as type. Ths keeps all values above your Threshold and sets all other Values to zero.

Please keep in mind that it is alway better to use the "Names" of this Parameters instead of their integer representation. If you read through your code in a few weeks cv::THRESH_TOZERO says everything you need, where 3 is only a number.

Mailerdaimon
  • 6,003
  • 3
  • 35
  • 46
  • thanks for the answer and for the good point. I will try to use Macro instead of using just numbers. thanks again :) – user2758510 Nov 04 '13 at 07:32