当前位置:网站首页>Matlab: obtain the figure edge contour and divide the figure n equally
Matlab: obtain the figure edge contour and divide the figure n equally
2022-06-13 02:30:00 【weixin_ forty-five million six hundred and thirty-three thousan】
Get the shape edge contour
Matlab It has a good effect in image processing , Use the following pictures as a demonstration 
Binary picture , Reuse Matlab Of edge Function to extract edges
clear;clc;
file_path='E:\file\matlab\';% Image folder path , Modified here
fprintf(' The image being read is :\n');
bw=0.3; % Adaptive threshold
img_name=[file_path,'stone1.png'];% file name , Modified here
pitch=imread(img_name);
pitch=rgb2gray(pitch);% Grayscale
pitch=histeq(pitch);% Enhance contrast
pitch=imadjust(pitch);
pitch=histeq(pitch);% Enhance contrast
pitch0=imadjust(pitch);
pitch=imbinarize(pitch0,bw);% Binary picture
w=fspecial('gaussian',[2,2],0.02);% Filtering noise reduction
pitch=imfilter(pitch,w);% Filtering noise reduction
pitch=edge(pitch,'sobel',0.01);% Edge extraction
% Extract contour coordinates , Can choose noholes Only search for objects
[Bound, L] = bwboundaries(pitch,8,'holes');
imshow(label2rgb(L, @jet, [.5 .5 .5]))
hold on
k=1; % For this reference figure , Take the first boundary for calculation
x=Bound{k}(:,2);% extract x coordinate
y=Bound{k}(:,1);% extract y coordinate
plot(x, y, 'w', 'LineWidth', 2)
hold on
X=sum(x); %x The coordinates and
x_average=X/length(x); % Center point x Coordinates of
Y=sum(y);%y The coordinates and
y_average=Y/length(y); % Center point y Coordinates of
plot(x_average, y_average, 'g*')
hold on
Get picture effects 
Put the figure n Equal division
Matlab There are already big men in the community John D’Errico Put the figure n The bisection function is written as a function :interparc , Can be in matlab Log in to the official website and download it directly to call .
stay Matlab Community File Exchange There are many excellent function functions contributed by big guys , This is also Matlab One of the features that makes it easy to use .
pt = interparc(24,x,y,'spline'); % n Bisection contour , here n take 24
plot(pt(:,1),pt(:,2),'b-o')
hold on
Get picture effects :
Complete code
Reference blog
边栏推荐
- Thinking back from the eight queens' question
- Open source video recolor code
- [pytorch]fixmatch code explanation - data loading
- Leetcode 473. 火柴拼正方形 [暴力+剪枝]
- Leetcode 93 recovery IP address
- Fast Color Segementation
- Swiper horizontal rotation grid
- ROS learning-6 detailed explanation of publisher programming syntax
- Image table solid line and dashed line detection
- Hstack, vstack and dstack in numpy
猜你喜欢

Chapter7-11_ Deep Learning for Question Answering (2/2)

Understand speech denoising

Huawei equipment is configured with dual reflectors to optimize the backbone layer of the virtual private network

Yovo3 and yovo3 tiny structure diagram
![[reading point paper] deeplobv3 rethinking atlas revolution for semantic image segmentation ASPP](/img/4e/a5c6b1a8880209f89d6bf252ff889a.jpg)
[reading point paper] deeplobv3 rethinking atlas revolution for semantic image segmentation ASPP

Branch and bound method, example sorting
![[reading some papers] introducing deep learning into the public horizon alexnet](/img/4b/6d9bafe48094ff6451efb211d83371.jpg)
[reading some papers] introducing deep learning into the public horizon alexnet

05 tabbar navigation bar function

Fast Color Segementation

在IDEA使用C3P0连接池连接SQL数据库后却不能显示数据库内容
随机推荐
ROS learning-6 detailed explanation of publisher programming syntax
js-dom
Several articles on norms
Branch and bound method, example sorting
Open source video recolor code
[pytorch] kaggle image classification competition arcface + bounding box code learning
Queuing theory, game theory, analytic hierarchy process
Solution of depth learning for 3D anisotropic images
0- blog notes guide directory (all)
CCF 201409-1: adjacent number pairs (100 points + problem solving ideas)
[keras] data of 3D u-net source code analysis py
在IDEA使用C3P0連接池連接SQL數據庫後卻不能顯示數據庫內容
The fastest empty string comparison method C code
Test questions basic exercise 01 string
redis. Conf general configuration details
Laravel permission export
redis.conf总配置详解
Leetcode 450. 删除二叉搜索树中的节点 [二叉搜索树]
Barrykay electronics rushes to the scientific innovation board: it is planned to raise 360million yuan. Mr. and Mrs. Wang Binhua are the major shareholders
Leetcode 93 recovery IP address