Borrar filtros
Borrar filtros

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 visualización (últimos 30 días)
%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

Respuestas (0)

Categorías

Más información sobre Import, Export, and Conversion en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2015a

Community Treasure Hunt

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

Start Hunting!

Translated by