How to apply a function to every element of a matrix
Show older comments
Hi, I have a RGB image which in MATLAB is in the form of a 3D matrix. The code:
angle_dimension = linspace(0,180,3);
cashew_RGB = imread('White Wholes 180.jpg');
cashew_BW = img_BW(cashew_RGB);
cashew_stats = regionprops(cashew_BW,'BoundingBox');
for i = 1:numel(cashew_stats)
cashew_single = imcrop(cashew_RGB,cashew_stats(i).BoundingBox);
cashew_single_BW = img_BW(cashew_single);
dim = imFeretDiameter(cashew_single_BW,angle_dimension);
end
The functions used are not really important. I want to know how I can eliminate the for loop. It is possible in my project that
numel(cashew_stats)
may return a large number and the for loop then would take a lot of time to execute. It would be immensely helpful if you could give me a technique to eliminate the for loop used. I have attached the image that I have used in the code. Thank You!
Accepted Answer
More Answers (0)
Categories
Find more on Creating and Concatenating Matrices in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!