Borrar filtros
Borrar filtros

Isolating one Texture from LBP

24 visualizaciones (últimos 30 días)
Veronica
Veronica el 11 de Jul. de 2024 a las 18:09
Respondida: Image Analyst el 20 de Jul. de 2024 a las 16:27
I'm trying to use local binary patterns to categorize/sort images into five categories. I'd like to be able to look at what textures are common in images from each category/what the numbers with the highest frequency in the LBP histograms relate to. I'm using extractLBPFeatures to get the LBP data.
Ideally, I'm aiming for something like this image above, however the same textures/features (edge, flat, corner) don't apply well to my images.

Respuestas (2)

Umar
Umar el 11 de Jul. de 2024 a las 19:40
Hi Veronica,
Are you familiar with extractLBPFeatures function in Matlab because this will help you extract the LBP features. Once you have the LBP histograms, you can identify the patterns with the highest frequencies to understand the prevalent textures in each image category. For more information on this function, please refer to:
https://www.mathworks.com/help/vision/ref/extractlbpfeatures.html Let me further illustrate with example in order to help achieve your goal.
So, I will use extractLBPFeatures function in MATLAB to compute the LBP features for your images. This function calculates the LBP features for each pixel in the image. Here's a basic example of how you can extract LBP features from an image:
% Read an image
img = imread('sample_image.jpg');
% Convert the image to grayscale
grayImg = rgb2gray(img);
% Extract LBP features
lbpFeatures = extractLBPFeatures(grayImg);
Once I have extracted the LBP features, I can analyze the LBP histograms to understand the texture patterns present in your images. The histogram values represent the frequency of different patterns in the image which will help you visualize these histograms to gain insights into the textures.
% Compute LBP histogram
lbpHistogram = imhist(lbpFeatures);
% Visualize the LBP histogram
bar(lbpHistogram);
title('LBP Histogram');
xlabel('LBP Patterns');
ylabel('Frequency');
Now, I will categorize images into five distinct categories based on their textures, you can use clustering algorithms such as k-means clustering. By clustering images using their LBP features, you can group similar textures together.
% Perform k-means clustering
numCategories = 5;
[idx, C] = kmeans(lbpFeatures, numCategories);
% Display the clustered categories
figure;
for i = 1:numCategories subplot(2, 3, i); imshow(img(idx == i)); title(['Category ', num2str(i)]); end
After categorizing the images, I can now analyze the clustered categories to identify common textures within each category and the LBP patterns with the highest frequency in the histograms will correspond to dominant textures present in the images belonging to a specific category. If you adjust parameters such as the LBP radius and number of points, you can further refine the analysis based on your specific image dataset.
  6 comentarios
Veronica
Veronica el 20 de Jul. de 2024 a las 11:52
Thank you, but how do I implement a thresholding or segmentation technique to highlight regions in the image?
Umar
Umar el 20 de Jul. de 2024 a las 15:57
Hi Veronica,
If you are trying to covnvert grayscale images to binary images on a specified threshold value then I would recommend using imbinarize function.
For more information to utilize this function in your code, please refer to
https://www.mathworks.com/help/images/ref/imbinarize.html

Iniciar sesión para comentar.


Image Analyst
Image Analyst el 20 de Jul. de 2024 a las 16:27
It's a generic, general purpose demo of how to threshold an image to find blobs, and then measure things about the blobs, and extract certain blobs based on their areas or diameters.
I'm also attaching my LBP demo, for what it's worth. It's not adapted to your data.
If you have an LBP image and want to find pixels having a particular LBP value, you can create a mask of those pixels and then call regionprops to measure things about the regions.
mask = lbpImage == yourDesiredValue; % A binary image.
props = regionprops(mask, 'Area', 'Perimeter') % List whatever measurements you want.
allAreas = [props.Area];
allPerims = [props.Perimeter];

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by