How can I crop the image from an specific boundary?
8 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello all,
I have a contour plot showing frost depth across the US (it is attached here). I want to crop the plot so that I would just have the entire US ( not anything outside the us borders). Can anyone help me with this regard?
0 commentaires
Réponses (1)
Daniel Bengtson
le 1 Août 2023
The mask and blur causes a bit of artifacting in the text, and there is obviously a bit of color outside of the boundaries. I'm sure others can do better, but here is a start.
im = imread('1FrostPlot_1_feet.png');
mask = im(:,:,1) < 50 & im(:,:,2) < 50 & im(:,:,3) < 50; % identify the dark borders between states/ocean
im2 = imgaussfilt(255*repmat(uint8(mask),1,1,3),1); % add a small amount of blur to close gaps in the boundaries
border = grayconnected(im2(:,:,1),10,10,1); % use the pixel at 10,10 to define connected color
border = repmat(border,1,1,3); % make mask the same shape as image
im(border) = 255; % set masked pixels to white
figure;
imshow(im)
0 commentaires
Voir également
Catégories
En savoir plus sur Contour Plots dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!