Question: testImageIdx = randi ( [ 1 , 3 ] ) testCoinImage = imread ( testCoinImage + testImageIdx + . png )
testImageIdx randi
testCoinImage imreadtestCoinImagetestImageIdxpng;
titleOriginal Coin Image";
testcoinMaskMaskedtestCoin segmentCointestCoinImage;
Shrink the coin mask.
se streldisk;
testcoinMask imfilltestcoinMask 'holes'; Fill any holes in it
testcoinMask imerodetestcoinMask se; Shrink by layers of pixels.
Find edges using original poster's code.
imgFilt imgaussfiltMaskedtestCoin
Padding"circular",FilterDomain"frequency",FilterSize;
faceEdgeMask edgeimgFilt"sobel","both";
Erase outside the shrunken coin mask to get rid of outer boundary.
faceEdgeMask~testcoinMask false;
imshowfaceEdgeMask;
titleEdge Mask Detection for Valid Coins"
se streldisk; You can adjust the disk size based on your requirements
dilatedFaceEdgeMask imdilatefaceEdgeMask se;
Step : Logical combination of dilated face edge mask and foreground mask
validCoinMask dilatedFaceEdgeMask & testcoinMask;
Step : Display the original image, testCoinMask, faceEdgeMask, and validCoinMask
figure;
subplot; imshowtestCoinImage; titleOriginal Image';
subplot; imshowtestcoinMask; titleForeground Mask';
subplot; imshowfaceEdgeMask; titleFace Edge Mask';
subplot; imshowvalidCoinMask; titleValid Coin Mask';
Step : Save the validCoinMask for further analysis or evaluation
savevalidCoinMaskmat", "validCoinMask";
function testcoinMaskMaskedtestCoin segmentCoinX
segmentImage Segment image using autogenerated code from Image Segmenter app
BWMASKEDIMAGE segmentImageX segments image X using autogenerated
code from the Image Segmenter app. The final segmentation is returned in
BW and a masked image is returned in MASKEDIMAGE.
Autogenerated by imageSegmenter app on Dec
X imgrayX;
Threshold image manual threshold
testcoinMask imgrayX;
Close mask with default
radius ;
decomposition ;
se streldisk radius, decomposition;
testcoinMask imclosetestcoinMask se;
Create masked image.
MaskedtestCoin X;
MaskedtestCoin~testcoinMask;
end
this is my code for the valid coin segmentations
testImageIdx
Figure of
the error imgetting is :
Assessment result: incorrectIs the valid coin mask correct?
Your coin mask is not capturing the full area of all valid coins.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
