How to update the variable of a function using a dialogbox?
Ältere Kommentare anzeigen
INTRO: I use the script below to track the shift of a pixel between two images:
clear all; close all;
prompt = {'CORRELATION SIZE:'};
dlg_title = 'SHIFTED PIXEL';
def = {'5'};
answer = inputdlg(prompt,dlg_title,[1 20],def);
CORRSIZE = str2num(answer{1,1}); %#ok<ST2NM>
base_points_0 = [56 37];
input_points_0 = [56 37];
imagea = imread('1.bmp');
imageb = imread('2.bmp');
image1 = rgb2gray(imagea);
image2 = rgb2gray(imageb);
d = zeros(1,2,2);
d(:,:,1) = base_points_0;
[input_points, base_points] = cpselect(image2,image1, input_points_0, base_points_0,'Wait', true);
updated_inputs = cpcorr(input_points, base_points, image2, image1);
d(:,:,2) = updated_inputs;
The shift of a pixel between two images is correct if the variable CORRSIZE found in line 76 of cpcorr.m is chosen properly. Therefore, I begin the script with a dialo-gbox to allow to chose the CORRSIZE before the script runs.
PROBLEM: CORRSIZE is updated only in the workspace but not in the function cpcorr.m and consequently I always have to open cpcorr.m from the command line, go to line 76 and change it manually.
I wonder if someone could write me how could I update CPCORR from a dialog-box incorporated in the current script and thus avoid to open cpcorr.m and do all steps manually.
I thank you in advance for your help Emerson
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Image Data Acquisition finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!