glcm

Compare the LBP in python

自闭症网瘾萝莉.ら 提交于 2020-01-13 02:53:26
问题 I generated a texture image like this I have to compare two textures. I have used histogram comparison method. image_file = 'output_ori.png' img_bgr = cv2.imread(image_file) height, width, channel = img_bgr.shape hist_lbp = cv2.calcHist([img_bgr], [0], None, [256], [0, 256]) print("second started") image_fileNew = 'output_scan.png' img_bgr_new = cv2.imread(image_fileNew) height_new, width_new, channel_new = img_bgr_new.shape print("second lbp") hist_lbp_new = cv2.calcHist([img_bgr_new], [0],

Compare the LBP in python

天大地大妈咪最大 提交于 2020-01-13 02:53:06
问题 I generated a texture image like this I have to compare two textures. I have used histogram comparison method. image_file = 'output_ori.png' img_bgr = cv2.imread(image_file) height, width, channel = img_bgr.shape hist_lbp = cv2.calcHist([img_bgr], [0], None, [256], [0, 256]) print("second started") image_fileNew = 'output_scan.png' img_bgr_new = cv2.imread(image_fileNew) height_new, width_new, channel_new = img_bgr_new.shape print("second lbp") hist_lbp_new = cv2.calcHist([img_bgr_new], [0],

Black line in GLCM result

帅比萌擦擦* 提交于 2020-01-11 12:00:13
问题 It is the result of GLCM matrix. What is the meaning of black horizontal and vertical lines in GLCM image? Are they a problem? N = numel(unique(img)); % img is uint8 glcm = graycomatrix(img, 'NumLevels', N); imshow(glcm) 回答1: I suspect this is the problem: For the function graycomatrix , You have supplied a 'NumLevels' argument which is larger than the number of unique graylevels in your image. For instance, a 256-level (8-bit) image will have only 256 graylevels. Asking for 1000 levels in

Calculating energy using MATLAB

血红的双手。 提交于 2019-12-30 07:39:08
问题 Energy, which is as follows: can be found based on the MATLAB documentation using: stats = graycoprops(glcm, properties) For example, I typed this: >> a = [1 2; 3 4] a = 1 2 3 4 >> stats = graycoprops(a, {'energy'}) stats = Energy: 0.3000 If we want to do this manually , how did we get the energy value shown above? This is the part I didn't get clearly. 回答1: If I'm not wrong: ans=sum(a(:).^2)/sum(a(:)).^2 来源: https://stackoverflow.com/questions/14599816/calculating-energy-using-matlab

Calculating entropy from GLCM of an image

和自甴很熟 提交于 2019-12-20 10:39:39
问题 I am using skimage library for most of image analysis work. I have an RGB image and I intend to extract texture features like entropy , energy , homogeneity and contrast from the image. Below are the steps that I am performing: from skimage import io, color, feature from skimage.filters import rank rgbImg = io.imread(imgFlNm) grayImg = color.rgb2gray(rgbImg) print(grayImg.shape) # (667,1000), a 2 dimensional grayscale image glcm = feature.greycomatrix(grayImg, [1], [0, np.pi/4, np.pi/2, 3*np

Matlab- Put rectangle on image

时光怂恿深爱的人放手 提交于 2019-12-13 05:17:10
问题 I have a sliding window on my image. If the average intensity within that window is > 210 then GLCM features are calculated on that window. If the GLCM features meet the conditions in the if statements then a rectangle should be drawn around this sliding window. I have tried this using the following code however the rectangle is not in the correct position on the image. I am unsure if I have put the code which draws the rectangle in the wrong place or if I have passed in the wrong coordinates

Sliding window in Python for GLCM calculation

*爱你&永不变心* 提交于 2019-12-12 09:57:23
问题 I am trying to do texture analysis in a satellite imagery using GLCM algorithm. The scikit-image documentation is very helpful on that but for GLCM calculation we need a window size looping over the image. This is too slow in Python. I found many posts on stackoverflow about sliding windows but the computation takes for ever. I have an example shown below, it works but takes forever. I guess this must be a a naive way of doing it image = np.pad(image, int(win/2), mode='reflect') row, cols =

OpenCV how to get GLCM gray-level co-occurrence matrix

时光毁灭记忆、已成空白 提交于 2019-12-12 02:55:00
问题 I am trying to extract features using GLCM (gray-level co-occurrence matrix (GLCM) from image) in OpenCV. In matlab we have graycomatrix . Does we have any function in openCV for the same purpose? If not, then what is the best solution to achieve it and is there any working example? [EDIT] I tried this code but it gives wrong values as compare to matlab result any better solution/function exist in OpenCV or am I doing any mistake in GLCM process? char rawdata[4][4] = { {0, 1, 2, 3}, {1, 1, 2,

the method of calculate the GLCM of a specific point in a image

て烟熏妆下的殇ゞ 提交于 2019-12-12 02:46:50
问题 As we know, GLCM (Grey Level Co-occurrence Matrix) describes the texture characteristics of images. But in usual, the calculation of GLCM in OpenCV, matlab often aim on a picture. But now I just want to get GLCM value of every single point inside the image, but how to get it? 回答1: If I understand your problem correctly, then perhaps you can just set the pixels outside your region of interest to NaN - these pixels are ignored by MATLAB when calculating the GLCM. For example: >> im = eye(7) im

MATLAB Anonymous function handle to use with NLFILTER

一笑奈何 提交于 2019-12-11 06:58:27
问题 I have the following function which calculates a GLCM and then a given statistic parameter. I would like to pass this function to NLFILTER to do the calculation for a whole image (in small windows, e.g. convolution). I already have then NLFILTER set up to run using the parallel computing toolbox, so I would really like to convert the function I have below: function [s]=glcm(img,meth) %GLCM calculates a Gray Level Co-occurence matrix & stats for a given sub % image. % Input: Sub Image (subI)