Just get the min and max value of your new array J
minJValue = min(J(:));
maxJValue = max(J(:));
imshow(yourOtherImage, [minJValue maxJValue]);
See the FAQ for ideas on sharing variables between functions: http://matlab.wikia.com/wiki/FAQ#How_can_I_share_data_between_callback_functions_in_my_GUI.3F
