24小时热门版块排行榜    

查看: 811  |  回复: 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 的主题更新
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[硕博家园] 售SCI-T0P文章,我:8O.5.5.1.O.54,科目齐全,可+急 +4 N80hyqiqCeT2 2026-11-26 4/200 2026-11-28 10:47 by Equinoxhua
[基金申请] 我的“飞艇+直升机”专利中了VFS的TVF 2027,求高校师生带写论文并参会 +3 95217 2026-11-26 3/150 2026-11-28 10:04 by kudofaye
[教师之家] 售SCI一区文章,我:8.O.55.1.O.54,科目齐全,可伽急 +8 1VHV9UkX7sid 2026-11-26 8/400 2026-11-27 22:05 by Uywcrj8sNxLZ
[考研] 售SCI-T0P文章,我:8O.5.5.1.O.54,科目齐全,可+急 +8 1VHV9UkX7sid 2026-11-26 8/400 2026-11-27 22:05 by Uywcrj8sNxLZ
[公派出国] 售SCI一区T0P文章,我:8O.55.1.O.5.4,科目齐全,可+急 +8 1VHV9UkX7sid 2026-11-26 12/600 2026-11-27 22:01 by Uywcrj8sNxLZ
[考研] 售SCI一区文章,我:8.O.55.1.O.54,科目齐全,可伽急 +3 1VHV9UkX7sid 2026-11-26 6/300 2026-11-27 22:00 by Uywcrj8sNxLZ
[找工作] 售SCI一区T0P文章,我:8.O.55.1.O.5.4,科目全,可+急 +3 p1TifTPkqG3A 2026-11-27 3/150 2026-11-27 19:55 by FlRlcTrDsDoO
[硕博家园] 售SCI一区文章,我:8O5.5.1.O5.4,科目全,可伽急 +3 I5Uih4YWUbaa 2026-11-27 3/150 2026-11-27 19:55 by FlRlcTrDsDoO
[硕博家园] 售SCI一区T0P文章,我:8.O.55.1.O.5.4,科目全,可+急 +3 J9NGDvAaPB9L 2026-11-26 3/150 2026-11-27 18:16 by XTPLXDTeEwbs
[教师之家] 售SCI一区文章,我:8.O.55.1.O.54,科目齐全,可伽急 +6 Gp6vMAD5C53H 2026-11-26 7/350 2026-11-27 17:54 by HaAiYedD27eq
[考博] 售SCI一区文章,我:8O5.5.1.O5.4,科目全,可伽急 +4 mzU8LdVQMwOf 2026-11-26 4/200 2026-11-27 17:43 by HaAiYedD27eq
[教师之家] 售SCI一区T0P文章,我:8.O.55.1.O.5.4,科目全,可+急 +4 mzU8LdVQMwOf 2026-11-26 4/200 2026-11-27 17:41 by HaAiYedD27eq
[找工作] 售SCI一区文章,我:8.O.551.O.5.4,科目全,可伽急 +6 mzU8LdVQMwOf 2026-11-26 8/400 2026-11-27 17:37 by HaAiYedD27eq
[博后之家] 售SCI文章,我:8O.5.5.1O.54,科目全,可十急 +4 mzU8LdVQMwOf 2026-11-26 4/200 2026-11-27 17:30 by HaAiYedD27eq
[公派出国] 售SCI一区文章,我:8.O.551.O.5.4,科目全,可伽急 +5 1VHV9UkX7sid 2026-11-26 6/300 2026-11-27 17:10 by HaAiYedD27eq
[考研] 售SCI一区T0P文章,我:8.O.55.1.O.5.4,科目全,可+急 +4 Gp6vMAD5C53H 2026-11-26 5/250 2026-11-27 13:19 by aTZfRIGzowsS
[考研] 售SCI一区文章,我:8.O.551.O.5.4,科目全,可伽急 +4 1VHV9UkX7sid 2026-11-26 4/200 2026-11-27 12:38 by aTZfRIGzowsS
[硕博家园] 售SCI文章,我:8O.5.5.1O.54,科目全,可十急 +5 1VHV9UkX7sid 2026-11-26 9/450 2026-11-27 08:08 by YSq3swkeEVgo
[考研] 售SCI一区T0P文章,我:8O.55.1.O.5.4,科目齐全,可+急 +3 mzU8LdVQMwOf 2026-11-26 3/150 2026-11-27 05:50 by p1TifTPkqG3A
[考博] 申博求助 10+3 charles.ww 2026-11-24 6/300 2026-11-26 21:27 by 13961805515
信息提示
请填处理意见