i just want to know if there are some parameters to make the lines more clear (or maybe another binary mehotd that i just missed)
You can make the lines more clear by further filtering. For example, in the guide you referenced, the threshold plays an important part because it identifies the missing objects on the two circuit boards. If the threshold was set to 0, then each tiny little white dot identified (which is likely due to different lighting - as suggested from the guide) would be considered a detection of a 'difference' between the two boards. Upping the threshold is important to detect segments that meet a minimum threshold of pixels.
but when i apply in my code the function of adaptive threshold the resulting image is not the result that i want (it has a lot of black spaces or the circuit lines are missing or bold) i try a lot of parameters but i cant find the good one.
There's a lot to consider for 'accurate' detection and getting what result you want because clusters of different pixels (as shown in an output 'xor' image) can vary in threshold throughout the board.
For your particular sitation, looking at the doc's for Imgproc.adaptiveThreshold
public static void adaptiveThreshold(Mat src,
Mat dst,
double maxValue,
int adaptiveMethod,
int thresholdType,
int blockSize,
double C)
I found the following parameters will likely help you configure a more acceptable threshold. Those parameters being (although all the parameters play an important role):
maxValue - Non-zero value assigned to the pixels for which the condition is satisfied. See the details below.
blockSize - Size of a pixel neighborhood that is used to calculate a threshold value for the pixel: 3, 5, 7, and so on.
C - Constant subtracted from the mean or weighted mean (see the details below). Normally, it is positive but may be zero or negative as well.
Let's say you have a maxValue of 255 (as per your original question state). Then a blockSize of 13, and a C of 10.
From my understanding, and please if an onlooker catches something off here, I'd benefit from the learning too, the 13 * 13 block is approx 169 total pixels and the threshold is 255 with a variation of a constant factor C or 10. So I don't think these numbers don't maximize their potential.
My suggested solutions:
- Take note and try to improve on the 5.0 Limitations as suggested in the guide/article you linked to following.
- Instead of searching the entire image, searching by parts of an image may increase accuracy as you can have variable thresholds for different parts of the image (e.g. if there's small differences with less noise in one corner of the image vs. large differences with more noise in another corner of the image - then you may potentially eliminate potential loss of legitimate clusters of missing parts when filtering)
Note: by posting the source images you are using and the code you are using to better help replicate the setup you have (see how to ask a good question)
Edit: See related for an example of adaptive threshold and openCV (related).