Calculating the range of pixel differences between two images
Show older comments
Hello all. As a beginner in writing a program in matlab related to imageprocessing, I have stuck in between and have no idea in moving forward. I wrote a program in matlab which reads two gray images and calculate the intensity difference between certain specified range of user input.
Now, I have to calculate the total sum of difference when the user gives multiple input ranges. That means the all the difference values must be stored and summed to get the final total difference. Additionally, I have used inputdlg to create the dialogue box where the user gives the input range. Please help me regarding this.
I have taken the x value from 1 to 15 which means the box appears 15 times for the input. When there are less input ranges to choose (may be 8 or 10), the program stops running if the cancel button is pressed in the input box. Please also suggest the necessary change to this in order to avoid the program to stop running in case of choosing the cancel button.
I have used the following code:
for x = 1:15
x = inputdlg('range:', 'pixel range', [1 255]);
data = str2num(x{:});
count1 = sum(im(:)>= min(str2num(x{:})) & im(:)<=max(str2num(x{:}));
count2 = sum(im2(:)>= min(str2num(x{:})) & im2(:)<=max(str2num(x{:}));
difference = abs(count1 - count2);
disp(difference)
end
Thanks in advance.
Accepted Answer
More Answers (0)
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!