clear; close all; clc;
rgb = imread('测试图像.jpg'); % Read the color image
if size(rgb, 3) == 3
I = rgb2gray(rgb);
else
I = rgb;
end
A = sum(I(:));
B = sum(I(:));
I1 = [1:numel(A)];
AS = A .* I1;
X = sum(AS) / sum(A);
J1 = [1:numel(B)];
BS = B .* J1;
Y = sum(BS) / sum(B);
X1 = max(1, round(X - 1000)); X2 = min(size(I, 2), round(X + 1000));
Y1 = max(1, round(Y - 1000)); Y2 = min(size(I, 1), round(Y + 1000));
S1 = (X1:1:X2);
C1 = (Y1:1:Y2);
figure(1);
imshow(I, []);
title('Center of gravity')
hold on;
plot(X, Y, 'r+');
hold on;
plot(X1, C1, 'r');
hold on;
plot(X2, C1, 'r');
hold on;
plot(S1, Y1, 'r');
hold on;
plot(S1, Y2, 'r');
FIN = I(Y1:Y2, X1:X2);
figure(2);
imshow(FIN, []);
title('The extraction results');
hold on; plot(1000, 1000, 'r+');
calzaghe
- 粉丝: 27
- 资源: 2
最新资源
- PFC理论基础与Matlab仿真模型学习笔记(1)-PFC电路概述
- 吞食天地2马腾传.nes
- 西部数据发布的一款西数硬盘检测修复工具-支持WD-L/WD-ROYL板,能进行硬盘软复位,可识别硬盘查看或清除-供大家学习参考
- wwwwwwwwwwwwwwwwwww
- 利用恒源云在云端租用GPU服务器训练YOLOv8模型(包括Linux系统命令讲解)_恒源云跑模型-CSDN博客.html
- python自学教程-12-sql注入和防止sql注入.ev4.rar
- python自学教程-11-pymsql对数据库的增删改操作.ev4.rar
- python自学教程-10-pymysql的查询语句操作.ev4.rar
- 计算机视觉处理设计开发工程师的专项培训
- Sigrity-XtractIM-template.rar
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈