I am trying to perform template matching on a carbon fiber filament. I extracted a template from the image. My o/p is only highlighting the extracted image and not all the fibers. I also want to count the number of fibers detected.

1 次查看(过去 30 天)
%Test code to perform template matching
%Date:Nov-13-2018
clear all
close all
clc
R=zeros();
%Importing Original Image
I=imread('filament.jpg');
%Converting the original image to grayscale
%Getting the size of the original image
[Ir, Ic] =size(I);
%Displaying the orignal image
figure (1)
imshow(I);
%Importing the template image
CROP=imread('carbon_fiber.jpg');
%Converting the cropped image into grayscale
T=rgb2gray(CROP);
%Getting the size of the matrix of the template
[Tr, Tc]=size(T);
figure (2)
imshow(T);
R=normxcorr2(T,I);
R=imcrop(R,[Tc Tr Ic Ir]);
[r, c, v]= find (R==max(max(R)));
RGB= insertShape(I,'rectangle',[c r Tc Tr],'LineWidth',3);
figure(3)
imshow(RGB);
carbon_fiber.JPG

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Import, Export, and Conversion 的更多信息

产品


版本

R2015a

Community Treasure Hunt

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

Start Hunting!

Translated by