24小时热门版块排行榜    

查看: 710  |  回复: 1

CSJ815

新虫 (初入文坛)

[求助] 求circle segment可视化代码

求circle segment可视化实现代码,最好是matlab写的。
回复此楼

» 收录本帖的淘帖专辑推荐

程序

» 猜你喜欢

已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

FMStation

至尊木虫 (知名作家)

【答案】应助回帖

CODE:
% Demo to write an ellipse into the overlay of an image,
% and then to burn those overlays into the image.

%----- Initializing steps -----
% Clean up
clc;
clear all;
close all;
fontSize = 14;
workspace; % Display the workspace panel.

% Change the current folder to the folder of this m-file.
if(~isdeployed)
        cd(fileparts(which(mfilename)));
end

hasIPT = license('test', 'image_toolbox');
if ~hasIPT
        % User does not have the toolbox installed.
        message = sprintf('Sorry, but you do not seem to have the Image Processing Toolbox.\nDo you want to try to continue anyway?');
        reply = questdlg(message, 'Toolbox missing', 'Yes', 'No', 'Yes');
        if strcmpi(reply, 'No')
                % User said No, so exit.
                return;
        end
end

% Display images to prepare for the demo.
monochromeImage = imread('pout.tif');
subplot(2, 3, 1);
imshow(monochromeImage);
title('Original Image', 'FontSize', fontSize);
subplot(2, 3, 2);
imshow(monochromeImage);
title('Draw ellipse in overlay here', 'FontSize', fontSize);
set(gcf, 'units','normalized','outerposition',[0 0 1 1]); % Maximize figure.
set(gcf,'name','Image Analysis Demo of imellipse() function','numbertitle','off')

%----- Burn ellipse into image -----
% Create elliptical mask, h, as an ROI object over the second image.
subplot(2, 3, 2);
userPrompt = sprintf(' Click and drag out an ellipse.\nDouble click inside of it to accept it.');
uiwait(msgbox(userPrompt));
hEllipse = imellipse(gca); % Second argument defines ellipse shape and position.
% Wait for user to finalize the size and location.
xyCoordinates = wait(hEllipse)

% Create a binary image ("mask") from the ROI object.
binaryImage = hEllipse.createMask();
% Display the ellipse mask.
subplot(2, 3, 3);
imshow(binaryImage);
title('Binary mask of the ellipse', 'FontSize', fontSize);

% Burn white ellipse into image by setting it to 255 wherever the mask is true.
outputImage = monochromeImage; % Re-initialize it.
outputImage(binaryImage) = 255;
% Display the image with the "burned in" ellipse.
subplot(2, 3, 4);
imshow(outputImage);
title('New image with ellipse burned into image', 'FontSize', fontSize);

% Burn black ellipse into image by setting it to 0 wherever the mask is true.
outputImage = monochromeImage; % Re-initialize it.
outputImage(binaryImage) = 0;
% Display the image with the "burned in" ellipse.
subplot(2, 3, 5);
imshow(outputImage);
title('New image with ellipse burned into image', 'FontSize', fontSize);

% Erase image outside of ellipse into image by setting it to 0 wherever the mask is true.
outputImage = monochromeImage; % Re-initialize it.
outputImage(~binaryImage) = 0;
% Display the image with the "burned in" ellipse.
subplot(2, 3, 6);
imshow(outputImage);
title('Image erased outside of ellipse', 'FontSize', fontSize);

2楼2016-10-09 23:12:39
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
相关版块跳转 我要订阅楼主 CSJ815 的主题更新
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[考研] 0856材料专硕353求调剂 +4 NIFFFfff 2026-03-20 4/200 2026-03-22 09:49 by 2026paper
[考研] 化学工程321分求调剂 +18 大米饭! 2026-03-15 22/1100 2026-03-21 20:20 by HH领袖
[考研] 0703化学调剂 ,六级已过,有科研经历 +14 曦熙兮 2026-03-15 14/700 2026-03-21 19:12 by ColorlessPI
[考研] 材料学硕333求调剂 +3 北道巷 2026-03-18 3/150 2026-03-21 18:17 by 学员8dgXkO
[考研] 298求调剂 +4 上岸6666@ 2026-03-20 4/200 2026-03-21 17:14 by 学员8dgXkO
[考研] 299求调剂 +5 shxchem 2026-03-20 7/350 2026-03-21 17:09 by ColorlessPI
[基金申请] 学校已经提交到NSFC,还能修改吗? 40+4 babangida 2026-03-19 9/450 2026-03-21 16:12 by babangida
[考研] 265求调剂 +12 梁梁校校 2026-03-19 14/700 2026-03-21 13:38 by lature00
[考研] 一志愿武理材料305分求调剂 +6 想上岸的鲤鱼 2026-03-18 7/350 2026-03-21 01:03 by JourneyLucky
[考研] 304求调剂 +6 曼殊2266 2026-03-18 6/300 2026-03-21 00:32 by JourneyLucky
[考研] 294求调剂材料与化工专硕 +15 陌の森林 2026-03-18 15/750 2026-03-20 23:28 by JourneyLucky
[考研] 324求调剂 +5 lucky呀呀呀鸭 2026-03-20 5/250 2026-03-20 22:30 by 促天成
[考研] 求调剂一志愿南京航空航天大学289分 +3 @taotao 2026-03-19 3/150 2026-03-20 21:34 by JourneyLucky
[考研] 一志愿 南京航空航天大学大学 ,080500材料科学与工程学硕 +5 @taotao 2026-03-20 5/250 2026-03-20 20:16 by JourneyLucky
[考研] 一志愿西安交通大学 学硕 354求调剂211或者双一流 +3 我想要读研究生 2026-03-20 3/150 2026-03-20 20:13 by JourneyLucky
[考研] 086500 325 求调剂 +3 领带小熊 2026-03-19 3/150 2026-03-20 18:38 by 尽舜尧1
[考研] 工科材料085601 279求调剂 +7 困于星晨 2026-03-17 9/450 2026-03-20 17:38 by 无懈可击111
[考研] 085410人工智能专硕317求调剂(0854都可以) +4 xbxudjdn 2026-03-18 4/200 2026-03-20 09:07 by 不168
[考研] 一志愿中国海洋大学,生物学,301分,求调剂 +5 1孙悟空 2026-03-17 6/300 2026-03-19 23:46 by zcl123
[考研] 一志愿苏州大学材料工程(085601)专硕有科研经历三项国奖两个实用型专利一项省级立项 +6 大火山小火山 2026-03-16 8/400 2026-03-17 15:05 by 无懈可击111
信息提示
请填处理意见