Удаление шума изображения на основе пространственных измерений

Просто добавьте что-то примечательное здесь.


myQueue.hpp:

template <class T> 
class QueueA {
    int size;
    ...
public:
    template <class T> T dequeue() {
       // implementation here
    }

    bool isEmpty();

    ...
}    

myQueue можно определить методы шаблонного класса, которые просто прекрасны в файле реализации. cpp:

// implementation of regular methods goes like this:
template <class T> bool QueueA<T>::isEmpty() {
    return this->size == 0;
}


main()
{
    QueueA<char> Q;

    ...
}
1
задан usr2564301 13 July 2018 в 17:29
поделиться

1 ответ

Если вы хотите только центральный blob, вы можете выбрать поиск контуров и выбрать ту, которая имеет максимальную площадь.

Код:

#--- convert image to grayscale ---
imgray = cv2.cvtColor(im,cv2.COLOR_BGR2GRAY)

#--- Perform Otsu threshold ---
ret2, th2 = cv2.threshold(imgray,0,255,cv2.THRESH_BINARY + cv2.THRESH_OTSU)
cv2.imshow('Threshold', th2)

В результате получается двоичное изображение :

#--- Finding contours using the binary image ---
 _, contours, hierarchy =    cv2.findContours(th2, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)

#--- finding the contour with the maximum area ---
big_contour = 0
max_area = 0

for cnt in contours:
    if (cv2.contourArea(cnt) > max_area):
        max_area = cv2.contourArea(cnt)
        big_contour = cnt

#--- creating a mask containing only the biggest contour ---
mask = np.zeros(imgray.shape)
cv2.drawContours(mask, [big_contour], 0, (255,255,255), -1)
cv2.imshow('Mask', mask)

#--- masking the image above with a copy of the original image ---
im2 = im.copy()
fin = cv2.bitwise_and(im2, im2, mask = mask.astype(np.uint8))
cv2.imshow('Final result', fin)

3
ответ дан Jeru Luke 17 August 2018 в 12:24
поделиться
Другие вопросы по тегам:

Похожие вопросы: