From: ImageAnalyst on
Seems to work for me. See this demo:

% function test()

% Change the current folder to the folder of this m-file.
% (The line of code below is from Brett Shoelson of The Mathworks.)
if(~isdeployed)
cd(fileparts(which(mfilename)));
end
clc; % Clear command window.
clear; % Delete all variables.
close all; % Close all figure windows except those created by imtool.
imtool close all; % Close all figure windows created by imtool.
workspace; % Make sure the workspace panel is showing.
fontSize = 20;
set(gcf, 'Position', get(0,'Screensize')); % Maximize figure.

% Read in standard MATLAB gray scale demo image.
grayImage = imread('cameraman.tif');
subplot(2, 2, 1);
imshow(grayImage, []);
title('Original Grayscale Image', 'FontSize', fontSize);
set(gcf, 'Position', get(0,'Screensize')); % Maximize figure.

a = grayImage;
[rows columns] = size(a)
s1 = 1.1
s2 = 1.15
b = 130;

vol = 255 * rand(rows, columns);
subplot(2, 2, 2);
imshow(vol, []);
title('Initial "vol" Image', 'FontSize', fontSize);

maskImage = a >= b;
subplot(2, 2, 3);
imshow(maskImage, []);
title('a >= b image', 'FontSize', fontSize);

vol(a>=b) = s1./s2 .* a(a>=b);
subplot(2, 2, 4);
imshow(vol, []);
title('Final "vol" Image', 'FontSize', fontSize);


First  |  Prev  | 
Pages: 1 2
Prev: "save" within a loop
Next: End of for loop very slow