33 views (last 30 days)

Image Analyst
on 18 Oct 2015

Don't use image. Use set(). See this demo:

grayImage = imread('moon.tif');

hImage = imshow(grayImage);

promptMessage = sprintf('Do you want to assign new pixels,\nor Quit?');

titleBarCaption = 'Continue?';

buttonText = questdlg(promptMessage, titleBarCaption, 'Continue', 'Quit', 'Continue');

if strcmpi(buttonText, 'Quit')

return;

end

for k = 1 : 50 : numel(grayImage);

grayImage(k) = 255; % Make this pixel bright white.

set(hImage, 'CData', grayImage);

end

msgbox('Done');

I think it should be fast enough for you.

Image Analyst
on 19 Oct 2015

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

Start Hunting!
## 9 Comments

## Direct link to this comment

https://ww2.mathworks.cn/matlabcentral/answers/249276-how-to-efficiently-update-an-image-if-one-matrix-element-is-changed#comment_317010

⋮## Direct link to this comment

https://ww2.mathworks.cn/matlabcentral/answers/249276-how-to-efficiently-update-an-image-if-one-matrix-element-is-changed#comment_317010

## Direct link to this comment

https://ww2.mathworks.cn/matlabcentral/answers/249276-how-to-efficiently-update-an-image-if-one-matrix-element-is-changed#comment_317018

⋮## Direct link to this comment

https://ww2.mathworks.cn/matlabcentral/answers/249276-how-to-efficiently-update-an-image-if-one-matrix-element-is-changed#comment_317018

## Direct link to this comment

https://ww2.mathworks.cn/matlabcentral/answers/249276-how-to-efficiently-update-an-image-if-one-matrix-element-is-changed#comment_317023

⋮## Direct link to this comment

https://ww2.mathworks.cn/matlabcentral/answers/249276-how-to-efficiently-update-an-image-if-one-matrix-element-is-changed#comment_317023

## Direct link to this comment

https://ww2.mathworks.cn/matlabcentral/answers/249276-how-to-efficiently-update-an-image-if-one-matrix-element-is-changed#comment_317033

⋮## Direct link to this comment

https://ww2.mathworks.cn/matlabcentral/answers/249276-how-to-efficiently-update-an-image-if-one-matrix-element-is-changed#comment_317033

## Direct link to this comment

https://ww2.mathworks.cn/matlabcentral/answers/249276-how-to-efficiently-update-an-image-if-one-matrix-element-is-changed#comment_317035

⋮## Direct link to this comment

https://ww2.mathworks.cn/matlabcentral/answers/249276-how-to-efficiently-update-an-image-if-one-matrix-element-is-changed#comment_317035

## Direct link to this comment

https://ww2.mathworks.cn/matlabcentral/answers/249276-how-to-efficiently-update-an-image-if-one-matrix-element-is-changed#comment_317039

⋮## Direct link to this comment

https://ww2.mathworks.cn/matlabcentral/answers/249276-how-to-efficiently-update-an-image-if-one-matrix-element-is-changed#comment_317039

## Direct link to this comment

https://ww2.mathworks.cn/matlabcentral/answers/249276-how-to-efficiently-update-an-image-if-one-matrix-element-is-changed#comment_317066

⋮## Direct link to this comment

https://ww2.mathworks.cn/matlabcentral/answers/249276-how-to-efficiently-update-an-image-if-one-matrix-element-is-changed#comment_317066

## Direct link to this comment

https://ww2.mathworks.cn/matlabcentral/answers/249276-how-to-efficiently-update-an-image-if-one-matrix-element-is-changed#comment_317095

⋮## Direct link to this comment

https://ww2.mathworks.cn/matlabcentral/answers/249276-how-to-efficiently-update-an-image-if-one-matrix-element-is-changed#comment_317095

## Direct link to this comment

https://ww2.mathworks.cn/matlabcentral/answers/249276-how-to-efficiently-update-an-image-if-one-matrix-element-is-changed#comment_317108

⋮## Direct link to this comment

https://ww2.mathworks.cn/matlabcentral/answers/249276-how-to-efficiently-update-an-image-if-one-matrix-element-is-changed#comment_317108

Sign in to comment.