How to determine height of a particular color in an image?
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Dear all,
I have series of images where i wanted to determine the height H.
First I converted it to hsv to obtain the following one -
After this what I can think of is:
Converting magenta color into matrix of pixel and identify distance between min and max value for each value. This way, I will have height at different columns, that I will average later to get average height (since, boundaries are not linear).
If somone can help me with the code or any lead, I will be thankful.
0 commentaires
Réponses (1)
yanqi liu
le 30 Nov 2021
Modifié(e) : yanqi liu
le 30 Nov 2021
clc; clear all; close all;
img = imread('https://www.mathworks.com/matlabcentral/answers/uploaded_files/817024/image.png');
jmg = rgb2ycbcr(img);
v = mat2gray(jmg(:,:,3));
bw = imbinarize(v,'adaptive');
bw2 = imclearborder(bw);
bw2 = bwareafilt(bw2, 1);
bw2 = imfill(bw2, 'holes');
stats = regionprops(bw2);
figure;
subplot(2,2,1); imshow(img);
hold on; rectangle('position', stats(1).BoundingBox, 'EdgeColor', 'g', 'LineWidth', 2)
subplot(2,2,2); imshow(v, []);
subplot(2,2,3); imshow(bw, []);
subplot(2,2,4); imshow(bw2, []);
fprintf('\nheight=%.1f\n',stats(1).BoundingBox(4));
0 commentaires
Voir également
Catégories
En savoir plus sur Read, Write, and Modify Image dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!