Example #1
0
    def extract(self):
        print 'Action: extract'

        customizableImage = CustomizableImage.load(self.__input)
        width, height = customizableImage.getDimensions()

        transform = WalshHadamardTransform()

        spectralY = customizableImage.getYData()
        if spectralY:
            y = transform.inverseTransformSequence(spectralY)
            y = self.__merge(y, width, height)
            y = np.array(y).reshape(-1).tolist()
            print len(y)
        else:
            y = [0] * (width * height)

        spectralCb = customizableImage.getCbData()
        if spectralCb:
            cb = transform.inverseTransformSequence(spectralCb)
            cb = self.__merge(cb, width, height)
            cb = np.array(cb).reshape(-1).tolist()
            print len(cb)
        else:
            cb = [128] * (width * height)

        spectralCr = customizableImage.getCrData()
        if spectralCr:
            cr = transform.inverseTransformSequence(spectralCr)
            cr = self.__merge(cr, width, height)
            cr = np.array(cr).reshape(-1).tolist()
            print len(cr)
        else:
            cr = [128] * (width * height)

        pixels = map(YCbCrColorModel().getRGB, zip(y, cb, cr))

        bmpImage = BMPImage()
        bmpImage.setDimensions(width, height)
        bmpImage.setRawData(pixels)
        bmpImage.save(self.__output)
Example #2
0
    def extract(self):
        print 'Action: extract'

        customizable_image = CustomizableImage.load(self.__input)
        width, height = customizable_image.get_dimensions()

        transform = WalshHadamardTransform()

        spectral_y = customizable_image.get_y_data()
        if spectral_y:
            y = transform.inverse_transform_sequence(spectral_y)
            y = self._merge(y, width, height)
            y = np.array(y).reshape(-1).tolist()
            print len(y)
        else:
            y = [0] * (width * height)

        spectral_cb = customizable_image.get_cb_data()
        if spectral_cb:
            cb = transform.inverse_transform_sequence(spectral_cb)
            cb = self._merge(cb, width, height)
            cb = np.array(cb).reshape(-1).tolist()
            print len(cb)
        else:
            cb = [128] * (width * height)

        spectral_cr = customizable_image.get_cr_data()
        if spectral_cr:
            cr = transform.inverse_transform_sequence(spectral_cr)
            cr = self._merge(cr, width, height)
            cr = np.array(cr).reshape(-1).tolist()
            print len(cr)
        else:
            cr = [128] * (width * height)

        pixels = map(YCbCrColorModel().get_rgb, zip(y, cb, cr))

        bmp_image = BMPImage()
        bmp_image.set_dimensions(width, height)
        bmp_image.set_raw_data(pixels)
        bmp_image.save(self.__output)