글
8월, 2016의 게시물 표시
[Octave] Color Homomorphic Filtering
- 공유 링크 만들기
- X
- 이메일
- 기타 앱
clear close all clc pkg load image I = imread('image16.jpg'); I = im2double(I); %figure(2);imshow(rgb2gray(I)) rr=I(:, :, 1); gg=I(:, :, 2); bb=I(:, :, 3); % Make Log I = log(1 + I); % mesh for H M = 2*size(I,1) + 1; N = 2*size(I,2) + 1; sigma = 5; [X, Y] = meshgrid(1:N,1:M); centerX = ceil(N/2); centerY = ceil(M/2); gaussianNumerator = (X - centerX).^2 + (Y - centerY).^2; H = 0.7*exp(-gaussianNumerator./(2*sigma.^2)); H = 1 - H + 0.9; H = fftshift(H); % fft fo image rf = fft2(rr, M, N); gf = fft2(gg, M, N); bf = fft2(bb, M, N); % product rout = real(ifft2(H.*rf)); gout = real(ifft2(H.*gf)); bout = real(ifft2(H.*bf)); rout = rout(1:size(I,1),1:size(I,2)); gout = gout(1:size(I,1),1:size(I,2)); bout = bout(1:size(I,1),1:size(I,2)); % -1 rhm = exp(rout) - 1; ghm = exp(gout) - 1; bhm = exp(bout) - 1; cc(:,:,1)= rhm; cc(:,:,2)= ghm; cc(:,:,3)= bhm; subplot(1, 2, 1);imshow(I) subplot(1, 2, 2);imshow(cc)
파이썬으로 Local Entropy Mapping
- 공유 링크 만들기
- X
- 이메일
- 기타 앱
import matplotlib.pyplot as plt import numpy as np from skimage import data from skimage.util import img_as_ubyte from skimage.filters.rank import entropy from skimage.morphology import disk # First example: object detection. noise_mask = 28 * np . ones (( 128 , 128 ), dtype = np . uint8 ) noise_mask [ 32 : - 32 , 32 : - 32 ] = 30 noise = ( noise_mask * np . random . random ( noise_mask . shape ) - 0.5 * noise_mask ) . astype ( np . uint8 ) img = noise + 128 entr_img = entropy ( img , disk ( 10 )) fig , ( ax0 , ax1 , ax2 ) = plt . subplots ( 1 , 3 , figsize = ( 8 , 3 )) ax0 . imshow ( noise_mask , cmap = plt . cm . gray ) ax0 . set_xlabel ( "Noise mask" ) ax1 . imshow ( img , cmap = plt . cm . gray ) ax1 . set_xlabel ( "Noisy image" ) ax2 . imshow ( entr_img ) ax2 . set_xlabel ( "Local entropy" ) fig . tight_layout () # Second example: texture detection. imag...
파이선으로 눈 인식하기: cv2
- 공유 링크 만들기
- X
- 이메일
- 기타 앱
import cv2 import sys cascPath = sys . argv [ 1 ] faceCascade = cv2 . CascadeClassifier ( cascPath ) video_capture = cv2 . VideoCapture ( 0 ) while True : # Capture frame-by-frame ret , frame = video_capture . read () gray = cv2 . cvtColor ( frame , cv2 . COLOR_BGR2GRAY ) faces = faceCascade . detectMultiScale ( gray , scaleFactor = 1.1 , minNeighbors = 5 , minSize = ( 30 , 30 ), flags = cv2 . cv . CV_HAAR_SCALE_IMAGE ) # Draw a rectangle around the faces for ( x , y , w , h ) in faces : cv2 . rectangle ( frame , ( x , y ), ( x + w , y + h ), ( 0 , 255 , 0 ), 2 ) # Display the resulting frame cv2 . imshow ( 'Video' , frame ) if cv2 . waitKey ( 1 ) & 0xFF == ord ( 'q' ): break # When everything is done, release the capture video_capture . release () cv2 . destroyAllWindows ()
파이썬으로 Histogram matching 하기.
- 공유 링크 만들기
- X
- 이메일
- 기타 앱
import numpy as np def hist_match ( source , template ): """ Adjust the pixel values of a grayscale image such that its histogram matches that of a target image Arguments: ----------- source: np.ndarray Image to transform; the histogram is computed over the flattened array template: np.ndarray Template image; can have different dimensions to source Returns: ----------- matched: np.ndarray The transformed output image """ oldshape = source . shape source = source . ravel () template = template . ravel () # get the set of unique pixel values and their corresponding indices and # counts s_values , bin_idx , s_counts = np . unique ( source , return_inverse = True , return_counts = True ) t_values , t_counts = np . unique ( template , return_counts = True ) ...
파이썬으로 Spectral Saliency Map 만들기
- 공유 링크 만들기
- X
- 이메일
- 기타 앱
rom skimage import img_as_float from skimage . io import imread from skimage . color import rgb2gray from scipy import fftpack , ndimage , misc from scipy . ndimage import uniform_filter from matplotlib . pyplot as plt # Read image from file image = img_as_float ( rgb2gray ( imread ( '1.jpg' ))) image = misc . imresize ( image , 64.0 / image . shape [ 0 ]) # Spectral Residual fft = fftpack . fft2 ( image ) logAmplitude = np . log ( np . abs ( fft )) phase = np . angle ( fft ) avgLogAmp = uniform_filter ( logAmplitude , size = 3 , mode = "nearest" ) #Is this same a applying "mean" filter spectralResidual = logAmplit...