img_denoised = med_filt_rgb(img);
img_gray = grayscale(img_denoised);
img_eq = adapthisteq(img_gray);
透過double threshold先設定域值找出水平線的角度,再透過hough轉換旋轉角度
threshold = [0.4 0.8];
img_edge = canny_no_border(img_eq, threshold);
[H, T, ~] = hough(img_edge);
theta_index = get_hline_theta_index(H);
rot_angle = -sign(T(theta_index)) * (90 - abs(T(theta_index)));
img_eq_rot = rotate_image(img_eq, rot_angle);
img_color_rot = rotate_image(img_denoised, rot_angle);
valid_mask = rotate_image(valid_mask, rot_angle, 'nearest');
threshold_detail = [0.4, 0.5];
img_edge_detail = canny_no_border(img_eq_rot, threshold_detail);
% figure,imshow(img_edge_detail);
[H, T, R] = hough(img_edge_detail);
H_horizontal = get_H_valid(H, 1, 3);
H_vertical = get_H_valid(H, 91, 3);
v_lines = get_vertical_lines(img_edge_detail, H_vertical, T, R);
h_lines = get_horizontal_lines(img_edge_detail, H_horizontal, T, R);
rect_car = get_car_rect(h_lines, v_lines);
car_edge_detail = edge(img_car_eq, 'Canny', [0.2 0.45]);
plate_mask = get_plate_mask(car_edge_detail);