Clear Filters
Clear Filters

Hello, I want to isolate and measure the bending of the following object, what is the correct isolating mechanism and how can I measure the angle?

2 views (last 30 days)

Answers (1)

Sai Pavan
Sai Pavan on 12 Feb 2024
Hello Omar,
I assume you want to isolate the pink object in the image and measure its bending angle. To isolate and measure the bending of an object like a cup in an image using MATLAB, one would typically identify the edge points manually after performing edge detection on the grayscale version of the image and then calculate the angle based on the chosen points.
Please refer the below code snippet of how you could implement this workflow:
image = imread('image.jpg'); % Read the image
grayImage = rgb2gray(image); % Convert to grayscale if the image is colored
enhancedImage = imadjust(grayImage); % Enhance the image
bwImage = imbinarize(enhancedImage); % Apply a binary threshold or use edge detection to segment
edges = edge(bwImage, 'Canny'); % Find the edges of the object using edge detection
imshow(edges); % Display the edges to manually identify the points for angle measurement
[x, y] = ginput(2); % Select two points along the bending line of the cup
m = (y2 - y1) / (x2 - x1); % Calculate the slope of the line
angleRadians = atan(m); % Calculate the angle in radians
angleDegrees = rad2deg(angleRadians); % Calculate the angle in degrees
disp(['The angle of bending is: ', num2str(angleDegrees), ' degrees']); % Display the angle
Hope it helps!

Tags

Community Treasure Hunt

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

Start Hunting!