- If edge count ≈ 0 → Empty
- If edge count ≈ value_one → Half-crowded
- If edge count ≈ value_full → Crowded
how get edge diffrance value between two images?
조회 수: 2 (최근 30일)
이전 댓글 표시
I am working on project to determine the crowded on the road using camera. the road may be(crowded/half crowded/empty).
My idea depend on get the difference between two images and get the edge of the difference and then calculate the value of the edge to determine the state of the road
>> full=imread('full.jpg');//read crowded road
>> one=imread('one.jpg'); //read one car on road
>> st=imread('st.jpg'); // read standard (empty) road
>> full=rgb2gray(full); //convert
>> one=rgb2gray(one);
>> dfull=full-st;// get the difference between two image
>> done=one-st;//get the difference between two image
>> efull=edge(dfull); //get the edge
>> eone=edge(done); // get the edge
Now I want get the value of efull and eone to compare between them
thanks
댓글 수: 0
답변 (1개)
Vidhi Agarwal
2025년 6월 10일
To quantify the difference between the images (i.e., calculate a "value" from the edge maps like efull and eone), simply sum up the number of edge pixels might help you with the issue.
Updated code for the same is given below:
% Read images
full = imread('full.jpg');
one = imread('one.jpg');
st = imread('st.jpg');
% Convert to grayscale
full = rgb2gray(full);
one = rgb2gray(one);
st = rgb2gray(st);
% Compute difference from empty road
dfull = imabsdiff(full, st);
done = imabsdiff(one, st);
% Detect edges
efull = edge(dfull, 'Canny'); % You can also try 'Sobel', 'Prewitt', etc.
eone = edge(done, 'Canny');
% Count number of edge pixels
value_full = sum(efull(:));
value_one = sum(eone(:));
% Display results
fprintf('Edge pixel count - Full: %d\n', value_full);
fprintf('Edge pixel count - One Car: %d\n', value_one);
The interpretation for the same is value_full > value_one > empty image edge count. And based on thresholds you define, you can say:
Hope this helps!
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!