牛全体の画像から耳標部分を取り出したい
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
clear all,close all
I = imread(['\耳標写真\252.jpg']);
%figure,imshow(I)
I_2 = yellowMask(I);
% figure,imshow(I_2,"InitialMagnification","fit")
I_3=imfill(I_2,'holes');
figure,imshow(I_3,"InitialMagnification","fit")
I_4 = repmat(I_3,[1 1 3]);
I_4 = uint8(I_4);
I_5 = I(:,:,:).*I_4(:,:,:);
figure,imshow(I_5,"InitialMagnification","fit")
% impixelinfo
% I_6 = createMask2(I_5);
%figure,imshow(I_6,"InitialMagnification","fit")
% impixelinfo
Ig = rgb2gray(I_5);
figure,imshow(Ig,"InitialMagnification","fit")
% impixelinfo
Ig2=Ig(:,:)<150&Ig(:,:)>10;
% figure,imshow(Ig2,"InitialMagnification","fit")
Ig3 = bwareaopen(Ig2,50);
figure,imshow(Ig3,"InitialMagnification","fit")
%
% J = histeq(Ig);
%
% BW = imbinarize(J);
% BW=uint8(BW);
% BW1=BW.*255;
% % figure,imshow(BW1,"InitialMagnification","fit")
% % impixelinfo
results = ocr(Ig3);
results.Text
results = ocr(Ig3,'CharacterSet','0123456789','TextLayout','Block');
results.Text
2 commentaires
Kojiro Saito
le 20 Déc 2022
@勇威 池畑さん、ご質問ありがとうございます。コードを記載いただいていますが、どこが聞きたい質問でしょうか? タイトルにやりたいことは書かれていますが、どこでエラーが出てしまうとか、どこがうまくいかない、とか書いていただけると回答を得やすいと思います。
Réponses (1)
Hernia Baby
le 20 Déc 2022
もしyellowMask関数を作りたいのであれば、
色の閾値アプリケーションの使用をオススメします。
I = imread('peppers.png');
[~,I2] = yellowMask(I);
montage({I,I2})
以下はアプリで作った関数です
function [BW,maskedRGBImage] = yellowMask(RGB)
I = rgb2hsv(RGB);
channel1Min = 0.092;
channel1Max = 0.146;
channel2Min = 0.352;
channel2Max = 1.000;
channel3Min = 0.850;
channel3Max = 1.000;
% Create mask based on chosen histogram thresholds
sliderBW = (I(:,:,1) >= channel1Min ) & (I(:,:,1) <= channel1Max) & ...
(I(:,:,2) >= channel2Min ) & (I(:,:,2) <= channel2Max) & ...
(I(:,:,3) >= channel3Min ) & (I(:,:,3) <= channel3Max);
BW = sliderBW;
% Initialize output masked image based on input image.
maskedRGBImage = RGB;
% Set background pixels where BW is false to zero.
maskedRGBImage(repmat(~BW,[1 1 3])) = 0;
end
Voir également
Catégories
En savoir plus sur イメージ タイプの変換 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!