0

I'm using scikit-image for computer vision. I will use find contours to obtain the contours of the grayscale image input but the list returned contain the contours in the image all in the first location. The result that I want to obtain is the only out contour of the image, for this reason I try to separate the contours with a for cycles but it requires very long time and the result is not good. Can anyone help me? The code is reported below:

import numpy as np
from skimage.io import imread
from skimage.measure import moments, moments_hu, find_contours, approximate_polygon
from skimage.feature import canny
from matplotlib import pyplot as plt
#%% Opening image section
reference_image = imread('referenceImage.jpg', as_gray= True)
reference_contours = find_contours(reference_image, 0.8, fully_connected='high')
first = True
added = False
reference_contours_list = []
for contours in reference_contours:
    for con in contours:
        if first:
            first = False
            reference_contours_list.append(np.array(np.array([con])))
        else:
            for index, past_con in enumerate(reference_contours_list):
                for past_c in past_con:
                    if con[0] in range(int(round(past_c[0])) - 1, int(round(past_c[0])) + 2):
                        reference_contours_list[index] = np.append(reference_contours_list[index], np.array(np.array([con])), axis=0)
  • Could you add your input image? – nathancy Oct 31 '19 at 00:21
  • "The result that I want to obtain is the only out contour of the image" Could you clarify this sentence? I'm still not sure exactly what you're after... – Juan Oct 31 '19 at 00:39
  • I can't upload the image because contain sensible data. You can find one example image on google or the image in this link "https://milano.repubblica.it/cronaca/2014/07/03/foto/un_volto_e_tanti_nomi_nei_guai_il_re_delle_false_identit-90612174/1/#1". So as you can see the contours that I want to find is the external contours of document and the contours of the two sections – Mameli Marco Oct 31 '19 at 06:08
  • Do you want to get the contour for upper rectangular shaped ID card ? – ZdaR Oct 31 '19 at 08:06
  • I have to obtain the the entire rectangular outer contour of the ID card and the two rectangular inside border of the two section – Mameli Marco Oct 31 '19 at 08:31

0 Answers0