trying to make a donut mask to span over images, suggestions?

12 visualizzazioni (ultimi 30 giorni)
Neo il 23 Feb 2023
Commentato: Neo il 24 Feb 2023
[x,y] = meshgrid(1:width, 1:height);
centerX = (width + 1) / 2;
centerY = (height + 1) / 2;
dist = sqrt((x - centerX).^2 + (y - centerY).^2);
masksign = grayImage >= lowThreshold & grayImage <= highThreshold;
0 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

Risposta accettata

Kevin Holly il 23 Feb 2023
imshow(RGBImage)
size(RGBImage)
ans = 1×3
384 512 3
width = 300;
height = 300;
[x,y] = meshgrid(1:width, 1:height);
centerX = (width + 1) / 2;
centerY = (height + 1) / 2;
dist = sqrt((x - centerX).^2 + (y - centerY).^2);
% masksign = grayImage >= lowThreshold & grayImage <= highThreshold;
figure
ans = 1×2
300 300
figure
3 CommentiMostra 1 commento meno recenteNascondi 1 commento meno recente
Kevin Holly il 24 Feb 2023
I am not sure what exactly you are trying to accomplish. Below, I rotated the images you create to show a half donut halved vertically.
width = 300;
height = 300;
% Create a meshgrid
[x,y] = meshgrid(1:width, 1:height);
% Set the center coordinates of the donut
centerX = (width + 1) / 2;
centerY = (height + 1) / 2;
% Calculate the distance of each point from the center
dist = sqrt((x - centerX).^2 + (y - centerY).^2);
% Set the radii of the inner and outer circles
% Create a logical array for the mask
% Set the region between the radii to true
% Set the region above the center to false
figure
stacked_vertically = [];
% Define the number of half donut masks to create
% Define the size of the image
width = 300;
height = 300;
% Calculate the width of each mask
% Create a meshgrid
[x,y] = meshgrid(1:width, 1:height);
% Calculate the center coordinates of the mask
centerX = (maskWidth * (i - 0.5));
centerY = (height + 1) / 2;
% Calculate the distance of each point from the center
dist = sqrt((x - centerX).^2 + (y - centerY).^2);
% Set the radii of the inner and outer circles
% Create a logical array for the mask
% Set the region between the radii to true
% Set the region above the center to false
end
figure
imshow(stacked_vertically)
Neo il 24 Feb 2023
Hi Dr. @Kevin Holly Thank you for this it really helped.
I am trying to get my attached script to work.
My code is attempting to count the number of dots (using a left half donut shaped mask) over 12 (or 9 the number is arbitrary) consecutive locations evenly distributed across the image and plot the count of the content as a function of the location.
My issues are the integer values are either not logical, or not positive and my code doesn't like that. Everytime I think I fix it, some other related error pops up. I thought the issue was the mask, then the maxDistance but now i am unsure. What would you suggest? Thank you.

Accedi per commentare.

Categorie

Scopri di più su Surface and Mesh Plots in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by