Exemplo n.º 1
0
 def calculate(self, resource):
     except_image_only(resource)
     im = image2numpy(resource.image, remap='gray')
     binary_im = np.uint8(im > 0)
     m = cv2.moments(binary_im)
     hu = cv2.HuMoments(m)
     return [hu.T]
Exemplo n.º 2
0
 def calculate(self, resource):
     except_image_only(resource)
     im = image2numpy(resource.image, remap='gray')
     feature = hog(im, orientations=4, pixels_per_cell=(8, 8), cells_per_block=(2, 2))
     feature = np.reshape(feature, (feature.size/16, 16)) # pylint: disable=no-member
     block_count = np.arange(feature.shape[0])
     return (feature, block_count)
Exemplo n.º 3
0
    def calculate(self, resource):
        except_image_only(resource)
        im = image2numpy(resource.image, remap='gray')
        keypoints = corner_peaks(corner_harris(im), min_distance=1)
        extractor = BRIEF_()
        extractor.extract(im, keypoints)

        #initalizing rows for the table
        return (extractor.descriptors, keypoints[:,0], keypoints[:,1])
Exemplo n.º 4
0
 def calculate(self, resource):
     """ Append descriptors to h5 table """
     except_image_only(resource)
     image_uri = resource.image
     #image_uri = BQServer().prepare_url(image_uri, remap='display')
     im = image2numpy(image_uri, remap='display')
     im = np.uint8(im)
     descriptors = extractSCD(im, descSize=256) #calculating descriptor
     return descriptors
Exemplo n.º 5
0
    def calculate(self, resource):
        #initalizing
        except_image_only(resource)
        image_uri = resource.image
        #image_uri = BQServer().prepare_url(image_uri, remap='gray')
        im = image2numpy(image_uri, remap='gray')
        descriptors = extractEHD(im)

        #initalizing rows for the table
        return descriptors
Exemplo n.º 6
0
    def calculate(self, resource):
        #initalizing
        except_image_only(resource)
        image_uri = resource.image
        #image_uri = BQServer().prepare_url(image_uri, remap='gray')
        im = image2numpy(image_uri, remap='gray')
        im = np.uint8(im)
        descriptors = extractEHD(im) #calculating descriptor

        return descriptors
Exemplo n.º 7
0
 def calculate(self, resource):
     except_image_only(resource)
     im = image2numpy(resource.image, remap='gray')
     extractor = ORB()
     extractor.detect_and_extract(im)
     return (extractor.descriptors,
             extractor.keypoints[:,0],
             extractor.keypoints[:,1],
             extractor.responses,
             extractor.scales,
             extractor.orientations)
Exemplo n.º 8
0
    def calculate(self, resource):
        #initalizing
        except_image_only(resource)

        image_uri = resource.image
        #image_uri = BQServer().prepare_url(image_uri, remap='display')
        im = image2numpy(image_uri, remap='display')
        im = np.uint8(im)
        descriptor = tas(im)

        #initalizing rows for the table
        return descriptor
Exemplo n.º 9
0
    def calculate(self, resource):
        #initalizing
        except_image_only(resource)

        image_uri = resource.image
        #image_uri = BQServer().prepare_url(image_uri, remap='gray')
        im = image2numpy(image_uri, remap='gray')
        im = np.uint8(im)
        #calculate descriptor
        descritptors = np.hstack(haralick(im))

        #initalizing rows for the table
        return descritptors
Exemplo n.º 10
0
    def calculate(self, resource):
        """ Append descriptors to SURF h5 table """
        #initalizing
        except_image_only(resource)

        image_uri = resource.image
        #image_uri = BQServer().prepare_url(image_uri, remap='gray')
        im = image2numpy(image_uri, remap='gray')
        im = np.uint8(im)
        descriptor = pftas(im)

        #initalizing rows for the table
        return descriptor
Exemplo n.º 11
0
 def calculate(self, resource):
     except_image_only(resource)
     im = image2numpy(resource.image, remap='gray')
     n00 = scale_invarient_moments(im, 0, 0)
     n01 = scale_invarient_moments(im, 0, 1)
     n10 = scale_invarient_moments(im, 1, 0)
     n11 = scale_invarient_moments(im, 1, 1)
     n02 = scale_invarient_moments(im, 0, 2)
     n20 = scale_invarient_moments(im, 2, 0)
     n03 = scale_invarient_moments(im, 0, 3)
     n30 = scale_invarient_moments(im, 3, 0)
     n21 = scale_invarient_moments(im, 2, 1)
     n12 = scale_invarient_moments(im, 1, 2)
     return np.array([n00, n01, n10, n11, n02, n02, n03, n30, n21, n12])
Exemplo n.º 12
0
 def calculate(self, resource):
     except_image_only(resource)
     im = image2numpy(resource.image, remap='gray')
     m00 = raw_moments(im, 0, 0)
     m01 = raw_moments(im, 0, 1)
     m10 = raw_moments(im, 1, 0)
     m11 = raw_moments(im, 1, 1)
     m02 = raw_moments(im, 0, 2)
     m20 = raw_moments(im, 2, 0)
     m03 = raw_moments(im, 0, 3)
     m30 = raw_moments(im, 3, 0)
     m21 = raw_moments(im, 2, 1)
     m12 = raw_moments(im, 1, 2)
     return  np.array([m00, m01, m10, m11, m02, m02, m03, m30, m21, m12])
Exemplo n.º 13
0
    def calculate(self, resource):
        #initalizing
        except_image_only(resource)

        image_uri = resource.image
        #image_uri = BQServer().prepare_url(image_uri, remap='gray')
        im = image2numpy(image_uri, remap='gray')
        im = np.uint8(im)
        radius = 8
        degree = 8
        descritptor = zernike_moments(im, radius, degree)

        #initalizing rows for the table
        return descritptor
Exemplo n.º 14
0
    def calculate(self, resource):
        #initalizing
        except_image_only(resource)
        image_uri = resource.image

        #image_uri = BQServer().prepare_url(image_uri, remap='gray')
        im = image2numpy(image_uri, remap='gray')
        im = np.uint8(im)
        width, height = im.shape
#        if width<128 and height<128:
#            raise FeatureExtractionError(resource, 415, 'Image\'s width and height must be greater than 128')
        descriptors = extractHTD(im) #calculating descriptor

        return descriptors
Exemplo n.º 15
0
 def calculate(self, resource):
     except_image_only(resource)
     im = image2numpy(resource.image, remap='gray')
     u00 = central_moments(im, 0, 0)
     u01 = central_moments(im, 0, 1)
     u10 = central_moments(im, 1, 0)
     u11 = central_moments(im, 1, 1)
     u02 = central_moments(im, 0, 2)
     u20 = central_moments(im, 2, 0)
     u03 = central_moments(im, 0, 3)
     u30 = central_moments(im, 3, 0)
     u21 = central_moments(im, 2, 1)
     u12 = central_moments(im, 1, 2)
     return np.array([u00, u01, u10, u11, u02, u02, u03, u30, u21, u12])
Exemplo n.º 16
0
    def calculate(self, resource):
        #initalizing
        except_image_only(resource)

        image_uri = resource.image
        #image_uri = BQServer().prepare_url(image_uri, remap='gray')
        im = image2numpy(image_uri, remap='gray')
        im = np.uint8(im)

        #calculating descriptor
        radius = 5
        points = 5
        descriptor = lbp(im, radius, points)

        #initalizing rows for the table
        return descriptor
Exemplo n.º 17
0
    def calculate(self, resource):
        """ Append descriptors to h5 table """
        except_image_only(resource)
        image_uri = resource.image
        feature_info = feature_list[self.name]
        tranforms = feature_info[1:3]
        #adds the correct delimiter
        if image_uri.count('?') < 1:
            image_uri += '?'
        else:
            image_uri += '&'

        args = []
        if feature_info[4] == True:
            #force the image to 3 channels prefered rgb
            args.append('remap=display')
        else:
            #force the image to be 1 channel
            args.append('remap=grey')

        for t in tranforms:
            if t != "Empty Transform":
                if t == "Hue Transform":
                    args.append('depth=8,d')
                    args.append(
                        'transform=rgb2hsv'
                    )  #converts rgb to hsv and then selects the hue channel
                    args.append('remap=1')
                else:
                    args.append('transform=' + t)
        args.append('format=tiff')  #return tiff format
        image_uri += '&'.join(args)

        log.debug('WNDCharm uri: %s' % image_uri)

        im = image2numpy(image_uri)
        extractWNDCharmFeature = feature_info[0]
        descriptor = extractWNDCharmFeature(im)

        #initalizing rows for the table
        return descriptor
Exemplo n.º 18
0
 def calculate(self, resource):
     except_image_only(resource)
     im = image2numpy(resource.image, remap='gray')
     min_length = np.min(im.shape) # pylint: disable=no-member
     return hog(im, pixels_per_cell=(min_length, min_length), cells_per_block=(1,1))
Exemplo n.º 19
0
 def calculate(self, resource):
     except_image_only(resource)
     im = image2numpy(resource.image, remap='gray')
     return rotation_invariant_moments(im)