How can I make a variable defined in one script make change also in a second script?

1 次查看(过去 30 天)
MOTIVATION: I wrote the following lines to obtain the distance of a give moving point between two images:
open cpcorr.m;
P2=4;
base_points_0 = [ 75 24 ];
input_points_0 =[ 75 24 ];
imagea = imread('0.bmp');
imageb = imread('1.bmp');
image1 = rgb2gray(imagea);
image2 = rgb2gray(imageb);
y = zeros(1,2,4);
[input_points, base_points] = cpselect(image2,image1, input_points_0, base_points_0, 'wait', true);
y(:,:,1) = base_points;
corrected_inputs = cpcorr(input_points, base_points, image2, image1);
y(:,:,2) = corrected_inputs;
input_points = corrected_inputs;
base_points = corrected_inputs;
filename1 = '1.bmp';
PROBLEM: The value 4 of variable P2 should be assigned to the correlation size (CORRSIZE = P2) in cpcorr.m but unfortunately I obtain the following error:
??? Undefined function or variable 'P2'.
Error in ==> cpcorr at 76
CORRSIZE = P2;
QUESTION: How can I write a value in the calculation script that makes a change in cpcorr.m without needing to change that number manually?
Thank you for your help
Emerson

采纳的回答

Junaid
Junaid 2012-2-5
Hi,
use global variables.
declare p2 as global.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Images 的更多信息

产品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by