• PUDN用户
    了解作者
  • matlab
    开发工具
  • 1KB
    文件大小
  • rar
    文件格式
  • 0
    收藏次数
  • 1 积分
    下载积分
  • 8
    下载次数
  • 2009-11-26 19:18
    上传日期
Draw_Circle()实现彩色圆形绘制,最后得到的图像为RGB图像
Draw_Circle.rar
  • Draw_Circle.m
    4.3KB
内容介绍
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%% Draw_Circle()实现彩色圆形绘制,最后得到的图像为RGB图像 %%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% function h = Draw_Circle(f,x0,y0,r) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% f —— 输入灰度图像 %% (x0,y0) —— 圆心坐标(x0->行序号;y0->列序号) %% r —— 圆的半径 %% h —— 输出真彩色图像,类型为RGB %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%改程序初始化坐标系转换没有必要了,画圆时又转了回去,增加了复杂性 % [FileName PathName]=uigetfile({'*.*','All Files(*.*)'},'choose a File'); % str=[PathName FileName]; % f=imread(str); % figure,imshow(f); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % r=52; % x0=338; % y0=214; %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% gray转换为rgb图像 [g,map]=gray2ind(f,256); % 灰度图像转化为索引图像 h=ind2rgb(g,map); % 索引图像转化为RGB图像 %% 十字标记圆心 % 竖线 h(x0-5:x0+5,y0,1) = 0; h(x0-5:x0+5,y0,2) = 1; h(x0-5:x0+5,y0,3) = 0; % 横线 h(x0,y0-5:y0+5,1) = 0; h(x0,y0-5:y0+5,2) = 1; h(x0,y0-5:y0+5,3) = 0; %% 按中点画圆的简便方法画圆 %% %% x_orig=0; y_orig=r; % x_new=x_orig+x0; % 列 % y_new=y_orig+y0; % 行 deltax=3; deltay=2-r-r; d=1-r; % [g,map]=gray2ind(f,256); % 灰度图像转化为索引图像 % h=ind2rgb(g,map); % 索引图像转化为RGB图像 % 圆上点行坐标向量和列坐标向量 x_orig_vector = [x_orig x_orig -x_orig -x_orig y_orig y_orig -y_orig -y_orig]; y_orig_vector = [y_orig -y_orig y_orig -y_orig x_orig -x_orig x_orig -x_orig]; x_new_vecoor = x_orig_vector + x0; y_new_vector = y_orig_vector + y0; %%%% 画初始点及其对称点 for i =1 : 8 h(x_new_vecoor(i),y_new_vector(i),1) = 0; h(x_new_vecoor(i),y_new_vector(i),2) = 1; h(x_new_vecoor(i),y_new_vector(i),3) = 0; end %%%% 画初始点(又转回行列) % h(y_new,x_new,1)=0;h(y_orig+y0,-x_orig+x0,1)=0;h(-y_orig+y0,x_orig+x0,1)=0;h(-y_orig+y0,-x_orig+x0,1)=0;h(x_orig+y0,y_orig+x0,1)=0;h(x_orig+y0,-y_orig+x0,1)=0;h(-x_orig+y0,y_orig+x0,1)=0;h(-x_orig+y0,-y_orig+x0,1)=0; % %%%%%%%%%%%%%%%% % h(y_new,x_new,2)=1;h(y_orig+y0,-x_orig+x0,2)=1;h(-y_orig+y0,x_orig+x0,2)=1;h(-y_orig+y0,-x_orig+x0,2)=1;h(x_orig+y0,y_orig+x0,2)=1;h(x_orig+y0,-y_orig+x0,2)=1;h(-x_orig+y0,y_orig+x0,2)=1;h(-x_orig+y0,-y_orig+x0,2)=1; % %%%%%%%%%%%%%%% % h(y_new,x_new,3)=0;h(y_orig+y0,-x_orig+x0,3)=0;h(-y_orig+y0,x_orig+x0,3)=0;h(-y_orig+y0,-x_orig+x0,3)=0;h(x_orig+y0,y_orig+x0,3)=0;h(x_orig+y0,-y_orig+x0,3)=0;h(-x_orig+y0,y_orig+x0,3)=0;h(-x_orig+y0,-y_orig+x0,3)=0; %%%%%%%%%%%%%%%%%%%% while x_orig<y_orig if d < 0 d=d + deltax; deltax = deltax +2; x_orig = x_orig + 1; else d = d + deltax + deltay; deltax = deltax +2; deltay = deltay +2; x_orig = x_orig + 1; y_orig = y_orig - 1; end % 圆上点行坐标向量和列坐标向量 x_orig_vector = [x_orig x_orig -x_orig -x_orig y_orig y_orig -y_orig -y_orig]; y_orig_vector = [y_orig -y_orig y_orig -y_orig x_orig -x_orig x_orig -x_orig]; x_new_vecoor = x_orig_vector + x0; y_new_vector = y_orig_vector + y0; %%%% 画圆上点及其对称点 for i =1 : 8 h(x_new_vecoor(i),y_new_vector(i),1) = 0; h(x_new_vecoor(i),y_new_vector(i),2) = 1; h(x_new_vecoor(i),y_new_vector(i),3) = 0; end % for % x_new=x_orig+x0; % y_new=y_orig+y0; % h(y_new,x_new,1)=0;h(y_orig+y0,-x_orig+x0,1)=0;h(-y_orig+y0,x_orig+x0,1)=0;h(-y_orig+y0,-x_orig+x0,1)=0;h(x_orig+y0,y_orig+x0,1)=0;h(x_orig+y0,-y_orig+x0,1)=0;h(-x_orig+y0,y_orig+x0,1)=0;h(-x_orig+y0,-y_orig+x0,1)=0; % %%%%%%%%%%%%%%%%% % h(y_new,x_new,2)=1;h(y_orig+y0,-x_orig+x0,2)=1;h(-y_orig+y0,x_orig+x0,2)=1;h(-y_orig+y0,-x_orig+x0,2)=1;h(x_orig+y0,y_orig+x0,2)=1;h(x_orig+y0,-y_orig+x0,2)=1;h(-x_orig+y0,y_orig+x0,2)=1;h(-x_orig+y0,-y_orig+x0,2)=1; % %%%%%%%%%%%%%%%%%%% % h(y_new,x_new,3)=0;h(y_orig+y0,-x_orig+x0,3)=0;h(-y_orig+y0,x_orig+x0,3)=0;h(-y_orig+y0,-x_orig+x0,3)=0;h(x_orig+y0,y_orig+x0,3)=0;h(x_orig+y0,-y_orig+x0,3)=0;h(-x_orig+y0,y_orig+x0,3)=0;h(-x_orig+y0,-y_orig+x0,3)=0; end % while % 显示效果图 % figure; % imshow(h); % figure; % subplot(121),imshow(f),title('原图'); % subplot(122),imshow(h),title('边界');
评论
    相关推荐
    • Draw2D.rar
      这是利用Java编写的一个绘制二维图形的Java程序,对Graphics2D进行了简单的使用。
    • DrawCircle.zip
      Function to draw a circle in matlab image
    • image-master.zip
      php图像处理,用php实现,进行简单的操作,编辑,修改等功能
    • incircle.zip
      该程序实现的功能:首先提取图片的轮廓,然后画出闭合轮廓的内切圆
    • draw_pipe_aapoint.rar
      Note: this looks a lot like draw_aaline.c but there s actually little if any code that can be shared.
    • draw-a-circle:只需使用Python和Pillow库绘制一个圆
      cd draw-a-circle 安装依赖项。 pip install Pillow 或者 python3 -m pip install Pillow 或者 sudo apt-get install python-pil 或者 sudo pip install pillow 或者 sudo easy_install pillow 用Python3打开 ...
    • Laravel开发-image
      Laravel开发-image 支持Laravel4集成的图像处理和操作库
    • tam-drawio:一个提供TAM标记的drawio插件
      tam-drawio 提供TAM表示法的插件 TAM是基于DIN 66200的UML2和FMC(基本建模概念)框图的子集-(数据处理系统操作;概念,工作关系,由Deutsches Institut Fur Normung EV(德国国家标准),1992年3月1日) 有关TAM...
    • sloth-draw:懒惰画
      抽奖 去做 防止您失去工作!!! 流量控制 装载怠速指示 在iPad上破解范围的东西 指数大小变化,因此您可以更好地控制小尺寸 上传速度更快! 和错误报告? 弄清楚为什么要休息 改变树懒大小的反馈 ...添加数据
    • codesforimageprocessing.rar
      实现简单图像处理,包括256色转灰度图、Hough变换、Walsh变换、中值滤波、二值化变换、亮度增减、傅立叶变换、反色、取对数、取指数、图像平移、图像旋转、图像细化、图像缩放、图像镜像、均值滤波、对比度拉伸、拉普拉斯锐化(边缘检测)、方块编码、梯度锐化、灰度均衡、直方图均衡、离散余弦变换、维纳滤波处理、逆滤波处理、阈值变换、高斯平滑。