Regional Descriptors in Image Description for DIP and its implementation in MATLAB || Description||

Поділитися
Вставка
  • Опубліковано 6 вер 2023
  • Video lecture series on Digital Image Processing, Lecture: 71,
    Regional Descriptors in Image Description for DIP and its implementation in MATLAB || Representation and Description||
    What are simple regional descriptors?
    What are topological descriptors?
    How to calculate Euler number?
    What are Textures?
    Implementation of Regional descriptors in MATLAB
    Link to download ppts/lecture notes:
    drive.google.com/drive/folder...
    #DIP
    #DIPwithMATLAB
    #DigitalImageProcessingUsingMATLAB
    #digitalimageprocessing
    #digitalimageprocessinglecturesin4K
    #studywithdrdafda
    The MATLAB code used in the video is given below:
    % MATLAB program for Simple Regional descriptors
    binary_image = zeros(100, 100);
    [x, y] = meshgrid(1:100, 1:100);
    circle = (x - 50).^2 + (y - 50).^2 (less than or equal to) 25^2;
    binary_image(circle) = 1; % Set circle region to 1 (white)
    % Calculate region properties
    stats = regionprops(binary_image, 'Area', 'Perimeter', 'BoundingBox');
    % Calculate Compactness, Circularity Ratio, Rectangularity, and Elongatedness
    area = stats.Area;
    perimeter = stats.Perimeter;
    boundingBoxArea = prod(stats.BoundingBox(3:4));
    circularity = (4 * pi * area) / (perimeter^2);
    circularityRatio = area / boundingBoxArea;
    rectangularity = area / boundingBoxArea;
    elongatedness = max(stats.BoundingBox(3:4)) / min(stats.BoundingBox(3:4));
    % Display the binary image with region properties
    imshow(binary_image);
    title('Binary Image with Region Properties');
    % Display calculated descriptors in the command window
    disp(['Area: ', num2str(area)]);
    disp(['Perimeter: ', num2str(perimeter)]);
    disp(['Compactness: ', num2str(4 * pi)]);
    disp(['Circularity Ratio: ', num2str(circularityRatio)]);
    disp(['Rectangularity: ', num2str(rectangularity)]);
    disp(['Elongatedness: ', num2str(elongatedness)]);
    % MATLAB program for Regional descriptors (Euler number calculation)
    % Create binary images with holes
    binary_image_one_hole = ones(100, 100); % Initialize with ones (white)
    binary_image_two_holes = ones(100, 100);
    binary_image_three_holes = ones(100, 100);
    % Create a hole
    [x1, y1] = meshgrid(1:100, 1:100);
    circle1 = (x1 - 50).^2 + (y1 - 50).^2 (less than or equal to) 25^2;
    binary_image_one_hole(circle1) = 0; % Set circle region to 0 (black)
    % Create two holes
    circle2 = (x1 - 30).^2 + (y1 - 30).^2 (less than or equal to) 10^2;
    circle3 = (x1 - 70).^2 + (y1 - 70).^2 (less than or equal to) 10^2;
    binary_image_two_holes(circle2) = 0; % Set circle regions to 0 (black)
    binary_image_two_holes(circle3) = 0;
    % Create three holes
    circle4 = (x1 - 25).^2 + (y1 - 75).^2 (less than or equal to)10^2;
    circle5 = (x1 - 50).^2 + (y1 - 50).^2 (less than or equal to) 10^2;
    circle6 = (x1 - 75).^2 + (y1 - 25).^2 (less than or equal to) 10^2;
    binary_image_three_holes(circle4) = 0; % Set circle regions to 0 (black)
    binary_image_three_holes(circle5) = 0;
    binary_image_three_holes(circle6) = 0;
    euler_number_one_hole = bweuler(binary_image_one_hole);
    euler_number_two_holes = bweuler(binary_image_two_holes);
    euler_number_three_holes = bweuler(binary_image_three_holes);
    subplot(1, 3, 1);
    imshow(binary_image_one_hole);
    title(['Binary Image with 1 Hole (Euler Number: ', num2str(euler_number_one_hole), ')']);
    subplot(1, 3, 2);
    imshow(binary_image_two_holes);
    title(['Binary Image with 2 Holes (Euler Number: ', num2str(euler_number_two_holes), ')']);
    subplot(1, 3, 3);
    imshow(binary_image_three_holes);
    title(['Binary Image with 3 Holes (Euler Number: ', num2str(euler_number_three_holes), ')']);
    disp(['Euler Number (1 Hole): ', num2str(euler_number_one_hole)]);
    disp(['Euler Number (2 Holes): ', num2str(euler_number_two_holes)]);
    disp(['Euler Number (3 Holes): ', num2str(euler_number_three_holes)]);
    % MATLAB program for Regional descriptors (Textures)
    %smooth texture
    smooth_texture = imbinarize(rand(100, 100), 0.5);
    % coarse texture (checkerboard pattern)
    coarse_texture = checkerboard(10, 5) (greater than) 0.5;
    regular_texture = repmat([zeros(1, 50), ones(1, 50)], 10, 1);
    % Compute texture descriptors
    co_occurrence_matrix = graycomatrix(regular_texture, 'Offset', [0 1]);
    % (2) Structural texture descriptors
    % - Apply edge detection
    edges = edge(coarse_texture, 'Sobel');
    % (3) Spectral texture descriptors
    fourier_transform = fft2(smooth_texture);
    % Display the generated textures
    subplot(2, 4, 1);
    imshow(smooth_texture);
    title('Smooth Texture');
    subplot(2, 4, 2);
    imshow(coarse_texture);
    title('Coarse Texture');
    subplot(2, 4, 3);
    imshow(regular_texture);
    title('Regular Texture');
    subplot(2, 4, 5);
    imshow(co_occurrence_matrix, []);
    title('Co-Occurrence Matrix');
    descriptor1 = mean(co_occurrence_matrix(:));
    subplot(2, 4, 6);
    imshow(edges);
    title('Edges');
    descriptor2 = sum(edges(:));
    subplot(2, 4, 7);
    imshow(log(abs(fourier_transform)), []);
    title('Fourier Transform (Log Magnitude)');
    % Additional subplot for better visualization
    subplot(2, 4, 8);
    imshow(angle(fourier_transform), []);
    title('Fourier Transform (Phase)');

КОМЕНТАРІ • 4

  • @user-yg6zy4pz2e
    @user-yg6zy4pz2e 7 місяців тому

    Very helpful ❤

  • @StudywithDrDafda
    @StudywithDrDafda  10 місяців тому

    % MATLAB program for Regional descriptors (Textures)
    clc;
    close all;
    clear all;
    % Create a binary image with a smooth texture
    smooth_texture = imbinarize(rand(100, 100), 0.5);
    % Create a binary image with a coarse texture (checkerboard pattern)
    coarse_texture = checkerboard(10, 5) > 0.5;
    % Create a binary image with a regular texture (stripes)
    regular_texture = repmat([zeros(1, 50), ones(1, 50)], 10, 1);
    % Compute texture descriptors
    % (1) Statistical texture descriptors
    % - Compute co-occurrence matrix
    co_occurrence_matrix = graycomatrix(regular_texture, 'Offset', [0 1]);
    % (2) Structural texture descriptors
    % - Apply edge detection
    edges = edge(coarse_texture, 'Sobel');
    % (3) Spectral texture descriptors
    % - Apply Fourier transform
    fourier_transform = fft2(smooth_texture);
    % Display the generated textures
    subplot(2, 4, 1);
    imshow(smooth_texture);
    title('Smooth Texture');
    subplot(2, 4, 2);
    imshow(coarse_texture);
    title('Coarse Texture');
    subplot(2, 4, 3);
    imshow(regular_texture);
    title('Regular Texture');
    % Display the computed descriptors
    subplot(2, 4, 5);
    imshow(co_occurrence_matrix, []);
    title('Co-Occurrence Matrix');
    descriptor1 = mean(co_occurrence_matrix(:));
    subplot(2, 4, 6);
    imshow(edges);
    title('Edges');
    descriptor2 = sum(edges(:));
    subplot(2, 4, 7);
    imshow(log(abs(fourier_transform)), []);
    title('Fourier Transform (Log Magnitude)');
    % Additional subplot for better visualization
    subplot(2, 4, 8);
    imshow(angle(fourier_transform), []);
    title('Fourier Transform (Phase)');
    % Adjust figure properties
    colormap('gray');

  • @StudywithDrDafda
    @StudywithDrDafda  10 місяців тому

    % MATLAB program for Regional descriptors (Euler number calculation)
    clc;
    close all;
    clear all;
    % Create binary images with holes
    binary_image_one_hole = ones(100, 100); % Initialize with ones (white)
    binary_image_two_holes = ones(100, 100);
    binary_image_three_holes = ones(100, 100);
    % Create a white circle (hole) in the first binary image
    [x1, y1] = meshgrid(1:100, 1:100);
    circle1 = (x1 - 50).^2 + (y1 - 50).^2

  • @StudywithDrDafda
    @StudywithDrDafda  10 місяців тому

    % MATLAB program for Simple Regional descriptors
    clc;
    close all;
    clear all;
    % Create a binary image with a shape (white region on a black background)
    binary_image = zeros(100, 100);
    [x, y] = meshgrid(1:100, 1:100);
    circle = (x - 50).^2 + (y - 50).^2