How can I compare the vector table values in matlab without using For loop?
Mostra commenti meno recenti
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 Commento
Jan
il 15 Mag 2013
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.
Risposte (1)
Jan
il 15 Mag 2013
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);
Categorie
Scopri di più su Scope Variables and Generate Names in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!