How can I compare the vector table values in matlab without using For loop?
이전 댓글 표시
I would like to compare pixel values of two images on vector table by converting them as black & with pictures. After executing simple code it turned out that all the pixel values had their range from 0(black) to around 256(white) and then I will subtract or compare of two corresponding pixels(which means in same location) to figure out how close each pixel value is between two images.
in order to make that code according to simple logic, it is clear than we can use 'for loop' for comparison. but it seems like the more we use 'for loop' in matlab code, the slower it becomes. therefore I just want to avoid 'for loop' if it is possible. is there any suggestion to implement this algorithm or code without 'for loop'??
댓글 수: 1
Jan
2013년 5월 15일
Please use the standard upper/lower case, because it improves the readability. Thanks.
If you post your FOR-loop approach, we can suggest improvements much easier than after reading your text explanations.
답변 (1개)
Jan
2013년 5월 15일
Pixel values from 0 to 256 are unusual. 0 to 255 would be the UINT8 range.
I do not understand, what you exactly want. Do I understand correctly, that you have two gray-scale images of the same size and the type UINT8? And you want to determine the distance or the difference between the pixel values? Then:
img1 = uint8(rand(200, 100) * 255);
img2 = uint8(rand(200, 100) * 255);
difference = img1 - img2;
distance = abs(difference);
카테고리
도움말 센터 및 File Exchange에서 Scope Variables and Generate Names에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!