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!