필터 지우기
필터 지우기

set elliptical ROI to zero in an image

조회 수: 1 (최근 30일)
Mohamed Amine Henchir
Mohamed Amine Henchir 2018년 8월 16일
댓글: Image Analyst 2018년 8월 27일
I'm using an algorithm to detect ellipses in an image, it returns the center major minor axis and the orientation, but I would like to delete the detected ones to avoid double detection. I believe the way to do it is to create a mask with an elliptical ROI set it to zero and then subtract it from the original image... anyone knows what function to use? tired to use imellipse but I couldn't figure out a way to get it to work with the detection algorithm.

채택된 답변

Image Analyst
Image Analyst 2018년 8월 16일
편집: Image Analyst 2018년 8월 16일
To erase your image where you have an elliptical mask, do
grayImage(mask) = 0;
See attached demo.
If you need more help, you'll have to post your existing code.
  댓글 수: 15
Mohamed Amine Henchir
Mohamed Amine Henchir 2018년 8월 27일
here is what I have, for now, I'm using the coordinates of a random ellipse and using poly2mask to create the mask and then subtracting it from the original image
if true
A = imread('one.jpg');
figure;
imshow(A);
hold on;
% Parameterize the equation.
t = linspace(0, 360,1000);
phaseShift = 0;
xAmplitude = 2;
yAmplitude = 1;
x = xAmplitude * sind(t + phaseShift);
y = yAmplitude * cosd(t);
mask = poly2mask(x, y, 256, 256);
A(mask)= 0;
imshow(A);
end
but nothing is happening!
Image Analyst
Image Analyst 2018년 8월 27일
Your x and y only went from 0-1 - less than a pixel! And your ellipse didn't have a center specified. Try this:
grayImage = imread('cameraman.tif');
subplot(2, 2, 1);
imshow(grayImage);
[rows, columns, numberOfColorChannels] = size(grayImage);
hold on;
% Parameterize the equation.
t = linspace(0, 360, 1000);
phaseShift = 0;
xAmplitude = columns/3;
yAmplitude = rows/5;
xCenter = columns/2;
yCenter = rows/2;
x = xAmplitude * sind(t + phaseShift) + xCenter;
y = yAmplitude * cosd(t) + yCenter;
mask = poly2mask(x, y, rows, columns);
subplot(2, 2, 2);
imshow(mask);
grayImage(mask)= 0;
subplot(2, 2, 3);
imshow(grayImage);

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Get Started with Image Processing Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by