What modification should i do for these broken edges (red arrow) ?
3 次查看(过去 30 天)
显示 更早的评论
I don't know why this marked edges are broken. but u see that all other edges are good. After median filtering i applied canny.Now my question is why these are bad ?. I applied another filter but in that these broken edges are good but other edges are broken.So what modification i do so that all horizontal edges will be fine ?
clear; close all;
global first_comp
%Input Image Raw Depth 512x424
A_depth_distance=imread('C:\Users\sufi\Desktop\matlab_kinect\Data_image\512x424\Best-Dataset\depth\arfin_depth.png');
% A_depth_distance=31.25*uint16(A_depth_distance);
figure,imshow(A_depth_distance,[0 4500]);
title('Input Image Raw Depth 512x424');
%Filtering the raw depth image Median
filtered_depth_distance=medfilt2(A_depth_distance,[3 3]);
figure,imshow(filtered_depth_distance,[0 4500]);
title('Filtering the raw depth image Median');
fill=imfill(filtered_depth_distance,'holes');
%Edge Detection Using Canny Operator
edges_depth_distance=edge(fill,'canny',[0 .009],4);
figure, imshow(edges_depth_distance);
title('Image obtained using Canny Operator');
Broken edges ( red arrow)
Raw Image
回答(1 个)
Vidhi Agarwal
2024-9-17
Hello @sufian ahmed
I understand that you are encountering issues with broken edges in your image processing workflow. These problems can arise from various factors, such as noise in the image, the parameters used in the Canny edge detector, or inherent characteristics of the image itself. Following recommendations might help you to resolve the issues, with their sample code implementation:
- Preprocessing: Implement additional preprocessing techniques, such as contrast enhancement and smoothing, to improve edge detection before applying the Canny edge detector.
clear; close all;
% Input Image Raw Depth 512x424
A_depth_distance = imread(‘path/to/your/image’);
% Display the original image
figure, imshow(A_depth_distance, [0 4500]);
title('Input Image Raw Depth 512x424');
% Filtering the raw depth image using Median filter
filtered_depth_distance = medfilt2(A_depth_distance, [3 3]);
figure, imshow(filtered_depth_distance, [0 4500]);
title('Filtered Depth Image with Median Filter');
- Modify Canny Parameters: The performance of the Canny edge detector is highly sensitive to its parameters. Consider experimenting with different thresholds and the standard deviation of the Gaussian filter used within the Canny operator.
% Fill holes in the filtered image
filled_depth_distance = imfill(filtered_depth_distance, 'holes');
% Edge Detection Using Canny Operator with adjusted parameters
edges_canny = edge(filled_depth_distance, 'canny', [0.005 0.02], 2);
figure, imshow(edges_canny);
title('Edges Detected using Canny Operator');
- Directional Filtering: If your primary interest is in horizontal edges, consider using a directional filter that emphasizes horizontal features, such as a horizontally oriented Sobel filter.
% Apply a Sobel filter to emphasize horizontal edges
horizontal_edges = edge(filled_depth_distance, 'sobel', 'horizontal');
figure, imshow(horizontal_edges);
title('Horizontal Edges Detected using Sobel Filter');
- Combine Edge Results: If different filters yield varying results, consider integrating their outputs to achieve a more comprehensive edge detection.
% Combine the results from Canny and Sobel
combined_edges = edges_canny | horizontal_edges;
figure, imshow(combined_edges);
title('Combined Edge Detection Results');
- Morphological Operations: Use morphological operations to fill in small gaps in the detected edges.
% Use morphological operations to close small gaps in the edges
se = strel('line', 3, 0); % A horizontal line structuring element
closed_edges = imclose(combined_edges, se);
figure, imshow(closed_edges);
title ('Final Edges with Morphological Closing');
The outputs for provided image will look like:
For better understanding of edge detection, Contrast enhancement, smoothing and morphological operation refer to the following documentation:
- https://www.mathworks.com/help/images/edge-detection.html
- https://www.mathworks.com/help/images/contrast-enhancement-techniques.html
- https://www.mathworks.com/help/images/apply-gaussian-smoothing-filters-to-images.html
- https://www.mathworks.com/help/images/morphological-filtering.html
Hope that Helps!
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!