牛全体の画像から耳標部分を取り出したい

5 visualizaciones (últimos 30 días)
勇威 池畑
勇威 池畑 el 20 de Dic. de 2022
Editada: Kojiro Saito el 6 de En. de 2023
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 comentarios
Kojiro Saito
Kojiro Saito el 20 de Dic. de 2022
@勇威 池畑さん、ご質問ありがとうございます。コードを記載いただいていますが、どこが聞きたい質問でしょうか? タイトルにやりたいことは書かれていますが、どこでエラーが出てしまうとか、どこがうまくいかない、とか書いていただけると回答を得やすいと思います。
勇威 池畑
勇威 池畑 el 20 de Dic. de 2022
現在は上のプログラミングから耳標部分をトリミングした画像では光学式文字認識を使って文字認識することができます。
今回は牛全体から耳標部分を取り出そうと考えております。自分では耳標が黄色なので閾値を用いて取り出せるのではないかと考えております。そして閾値の設定で困っています。
つたない文章で申し訳ございません。アドバイス宜しくお願いします。
下が現在考えているプログラミングです。
clear all;close all;clc
I = imread('\耳標写真\牛舎.png');
HSV = rgb2hsv(I);
Hue = HSV(:,:,1);
Hue = HSV(:,:,2);
Hue = HSV(:,:,3);
figure,
%subplot(2,2,1),
figure,imshow(Hue,"InitialMagnification","fit")
impixelinfo

Iniciar sesión para comentar.

Respuestas (1)

Hernia Baby
Hernia Baby el 20 de Dic. de 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
  1 comentario
勇威 池畑
勇威 池畑 el 20 de Dic. de 2022
ありがとうございました。活用させていただきます!

Iniciar sesión para comentar.

Etiquetas

Community Treasure Hunt

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

Start Hunting!