Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Image gets rescaling after normalize using opencv and scikit-image

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

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))
    plt.imshow(EQU2, cmap="gray")
    plt.show()

#CIERRA
cv2.destroyAllWindows()
camera.release()

Image gets rescaling after normalize using opencv and scikit-image

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))
    plt.imshow(EQU2, FRA = fil.frangi(EQU2)
    cv2.imshow("FRA",FRA)
    #plt.imshow(FRA, cmap="gray")
    plt.show()

#CIERRA
cv2.destroyAllWindows()
camera.release()