Exemplo n.º 1
0
 def test_all(self):
     to_pil(stretch(from_pil(self.img)))
     to_pil(grey_world(from_pil(self.img)))
     to_pil(retinex(from_pil(self.img)))
     to_pil(max_white(from_pil(self.img)))
     to_pil(retinex_with_adjust(retinex(from_pil(self.img))))
     to_pil(
         standard_deviation_weighted_grey_world(from_pil(self.img), 20, 20))
     to_pil(
         standard_deviation_and_luminance_weighted_gray_world(
             from_pil(self.img), 20, 20))
     to_pil(luminance_weighted_gray_world(from_pil(self.img), 20, 20))
     to_pil(automatic_color_equalization(from_pil(self.img)))
Exemplo n.º 2
0
def mix_brock():
    img_src1 = cv.imread("./img/1.png", 1)
    img_src2 = cv.imread("./img/2.png", 1)
    img_src3 = cv.imread("./img/3.png", 1)

    try:
        pal = cv.getTrackbarPos('hoge', winName)
    except:
        pal = 150

    img_ave = img_src1 * (1 / 3) + img_src2 * (1 / 3) + img_src3 * (
        1 / 3) + pal - 150
    cv.imwrite("./img/mix.png", img_ave)
    img = Image.open('./img/mix.png')

    to_pil(cca.grey_world(from_pil(to_pil(cca.stretch(
        from_pil(img)))))).save('./img/block.png')
    try:
        pal2 = cv.getTrackbarPos('hige', winName)
    except:
        pal2 = 0

    if pal2 == 0:
        to_pil(cca.grey_world(from_pil(to_pil(cca.stretch(
            from_pil(img)))))).save('./img/block.png')
    elif pal2 == 1:
        to_pil(cca.retinex_with_adjust(cca.retinex(
            from_pil(img)))).save('./img/block.png')
    elif pal2 == 2:
        to_pil(cca.stretch(from_pil(img))).save('./img/block.png')
Exemplo n.º 3
0
    def retinex_eq(self, img):
        # convert to pil format
        img_pil = self.opencv_to_pil(img)
        img_ret_pil = to_pil(cca.retinex(from_pil(img_pil)))
        img_ret_opencv = cv2.cvtColor(np.array(img_ret_pil), cv2.COLOR_RGB2BGR)

        return img_ret_opencv
Exemplo n.º 4
0
def applyEffectsACE_RETINEX(count, filename, file):
    print("{0} > apply ACE/RETINEX em {1}".format(count, filename))
    chaveF = filename[28:36]
    nomeParaSalvar = pastaSaida + chaveF + '_' + file
    img = Image.open(filename)
    img = to_pil(cca.automatic_color_equalization(from_pil(img)))
    img = to_pil(cca.retinex(from_pil(img)))
    img.save(nomeParaSalvar)
Exemplo n.º 5
0
import colorcorrect.algorithm as cca
import numpy as np
import sys


def from_pil(pimg):
    pimg = pimg.convert(mode='RGB')
    nimg = np.array(pimg)[:]
    # nimg.flags.writeable = True
    return nimg


def to_pil(nimg):
    return Image.fromarray(np.uint8(nimg))


if __name__ == "__main__":
    img = Image.open(sys.argv[1])
    # img.show()
    to_pil(cca.stretch(from_pil(img)))
    to_pil(cca.grey_world(from_pil(img)))
    to_pil(cca.retinex(from_pil(img)))
    to_pil(cca.max_white(from_pil(img)))
    to_pil(cca.retinex_with_adjust(cca.retinex(from_pil(img))))
    to_pil(cca.standard_deviation_weighted_grey_world(from_pil(img), 20, 20))
    to_pil(
        cca.standard_deviation_and_luminance_weighted_gray_world(
            from_pil(img), 20, 20))
    to_pil(cca.luminance_weighted_gray_world(from_pil(img), 20, 20))
    to_pil(cca.automatic_color_equalization(from_pil(img)))
Exemplo n.º 6
0
# background *= 1./255
print background.shape
background = cv2.cvtColor(background, cv2.COLOR_RGB2GRAY)
background = background / 255.0
print background.shape
print np.amax(background)

mu = 0.05

for f in xrange(nFrames):
    s, frameImg = vidFile.read()
    if f % 10 == 0:
        gray = cv2.cvtColor(frameImg, cv2.COLOR_RGB2GRAY)
        retinexed = np.zeros([gray.shape[0], gray.shape[1], 3])
        for i in range(2):
            retinexed[:, :, i] = gray
        retinexed = cca.retinex(retinexed)
        retinexed = cv2.cvtColor(retinexed, cv2.cv.CV_BGR2GRAY)
        cv2.imshow("retinexed frame", retinexed)
        retinexed = retinexed / 255.0
        background = (1 - mu) * background + mu * retinexed
        # print background
        # background=cv2.cvtColor(background,cv2.CV_8U)
    cv2.imshow("Original Frame", utils.rotateImg(frameImg))
    cv2.imshow("My Video Window", utils.rotateImg(background))
    cv2.waitKey(waitPerFrameInMillisec)

# # When playing is done, delete the window
# #  NOTE: this step is not strictly necessary,
# #         when the script terminates it will close all windows it owns anyways
# cv2.DestroyWindow( "My Video Window" )
Exemplo n.º 7
0
# -*- coding: utf-8 -*-
import sys
from PIL import Image
from colorcorrect.algorithm import stretch, grey_world, retinex, retinex_with_adjust, max_white
from colorcorrect.algorithm import standard_deviation_weighted_grey_world
from colorcorrect.algorithm import standard_deviation_and_luminance_weighted_gray_world
from colorcorrect.algorithm import automatic_color_equalization
from colorcorrect.algorithm import luminance_weighted_gray_world
from colorcorrect.util import from_pil, to_pil

if __name__ == "__main__":
    img = Image.open(sys.argv[1])
    # img.show()
    to_pil(stretch(from_pil(img)))
    to_pil(grey_world(from_pil(img)))
    to_pil(retinex(from_pil(img)))
    to_pil(max_white(from_pil(img)))
    to_pil(retinex_with_adjust(retinex(from_pil(img))))
    to_pil(standard_deviation_weighted_grey_world(from_pil(img), 20, 20))
    to_pil(
        standard_deviation_and_luminance_weighted_gray_world(
            from_pil(img), 20, 20))
    to_pil(luminance_weighted_gray_world(from_pil(img), 20, 20))
    to_pil(automatic_color_equalization(from_pil(img)))