Image gets rescaling after normalize using opencv and scikit-image

asked 2018-08-14 17:40:21 -0600

pipeecs780 gravatar image

updated 2018-08-14 19:21:59 -0600

Hello, I'm tryng to combine OPENCV and scikit-image to image processing. I need to do some histograms equalizations and aplly some filters too, but I need first to normalize the video to keep the values beetween 0 and 1. The problem is after I normalize the image in grayscale and tray to do an histogram equalization, the image gets rescale to 0 to 255. I don't know why this happens. Any ideas?

Greetings

import matplotlib.pyplot as plt
import matplotlib.image as img
import numpy as np
import cv2
import numpy as np
import matplotlib.pyplot as plt
from skimage.io import imread
from skimage.transform import radon, iradon
import skimage.filters as fil
from skimage import exposure
from skimage.morphology import disk
from skimage.transform import resize
from skimage.morphology import erosion, dilation, opening, closing, white_tophat
from skimage.color import rgb2gray

#IM=img.imread("img01.jpg")
#nF,nC=IM.shape #Obtiene el tamaño de la imagen



camera = cv2.VideoCapture(0)
cv2.namedWindow('Ventana1')

while cv2.waitKey(1)==-1:

    retval, img = camera.read()
    img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
    img2 = cv2.normalize(img, None, alpha=0, beta=1, norm_type=cv2.NORM_MINMAX, dtype=cv2.CV_32F)

    EQU = fil.rank.equalize(img2, disk(120))
    EQU2 = fil.rank.equalize(EQU, disk(25))
    FRA = fil.frangi(EQU2)
    cv2.imshow("FRA",FRA)
    #plt.imshow(FRA, cmap="gray")
    plt.show()

#CIERRA
cv2.destroyAllWindows()
camera.release()
edit retag flag offensive close merge delete

Comments

whatever fil.rank.equalize does, -- not an opencv problem.

berak gravatar imageberak ( 2018-08-14 19:22:08 -0600 )edit

Because cv2.normalize(img, None, alpha=0, beta=1, norm_type=cv2.NORM_MINMAX, dtype=cv2.CV_32F). When alpha its 0 and beta 1, to do the rescale from 0 to 255 that allow me to do the equalize and frangi filter If I want to work with grayscale images.

pipeecs780 gravatar imagepipeecs780 ( 2018-08-14 19:22:40 -0600 )edit

yea,sorry, i missed it , originally.

but again, we can't help you with scikit.

berak gravatar imageberak ( 2018-08-14 19:23:41 -0600 )edit