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

2 visualizaciones (últimos 30 días)
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

Respuesta aceptada

Junaid
Junaid el 5 de Feb. de 2012
Hi,
use global variables.
declare p2 as global.

Más respuestas (0)

Categorías

Más información sobre Read, Write, and Modify Image en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by