how to save many image into mat file??
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
i have trouble to save all images pixel into mat file. the number of image according to looping k, this is the code:
for k = 1 : y * x % Loop through all character
thisCharsBoundingBox = Iprops(k).BoundingBox; %Get list of pixels in current character.
subImage = imcrop(skeleton2, thisCharsBoundingBox);
imsize=imresize(subImage, [20 20]);%images size be 20x20 pixel
subplot(12, 8, k, 'Parent',handles.panel_pattern,'Position',[1 1 1 1]); %show the image in panel
imshow(imsize);
save image imsize;
end
it just save one images pixel., can anyone help me to solve this trouble...
4 comentarios
Image Analyst
el 2 de Oct. de 2011
imwrite DOES save the pixel values of the image. Maybe you just need to cast your subimage from logical to uint8 before you call imwrite. Then like Walter says, simply use imread to read the image back in from disk. Don't worry, it will have the correct values.
Respuesta aceptada
Grzegorz Knor
el 1 de Oct. de 2011
save(['image' num2str(k), 'imsize');
See also:
2 comentarios
Image Analyst
el 1 de Oct. de 2011
Again "Any reason why you're not using imwrite() to save it as a regular image format file?"
Más respuestas (1)
Image Analyst
el 1 de Oct. de 2011
Regarding your comment about getting the mean in blocks, it might be a little advanced, but would you consider doing it in just 2 or 3 lines (or even 1 if you combine them) by using blockproc()? Here's a full-blown demo - don't be afraid the main part is only 2 lines in the middle, the rest is just tutorial stuff.
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
imtool close all; % Close all imtool figures.
clear; % Erase all existing variables.
workspace; % Make sure the workspace panel is showing.
fontSize = 16;
% Create sample image.
grayImage = uint8(255*rand(20,20));
[rows columns numberOfColorChannels] = size(grayImage);
% Display the original image.
subplot(1, 2, 1);
imshow(grayImage, []);
caption = sprintf('Original Image\n%d by %d pixels', ...
rows, columns);
title(caption, 'FontSize', fontSize);
% Enlarge figure to full screen.
set(gcf, 'units','normalized','outerposition',[0 0 1 1]); % Maximize figure.
set(gcf, 'name','Demo by ImageAnalyst', 'numbertitle','off')
% Now let's use an anonymous function and the blockproc function.
% This is the real meat of the program, these 3 lines.
% We'll take the mean in the 5 by 5 blocks and get out a 4 by 4 image.
windowSize = 5;
myFilterHandle = @(block_struct) mean2(block_struct.data);
blockyImageMean = blockproc(grayImage, [windowSize windowSize], myFilterHandle);
% Done! Now let's display it.
subplot(1, 2, 2);
imshow(blockyImageMean, []);
[rowsMean columnsMean numberOfColorChannelsMean] = size(blockyImageMean);
caption = sprintf('Image Processed in %d by %d Blocks\nWith an Anonymous Mean Filter\nto produce an image %d by %d pixels', ...
windowSize, windowSize, rowsMean, columnsMean);
title(caption, 'FontSize', fontSize);
msgbox('Done with demo!');
6 comentarios
Image Analyst
el 2 de Oct. de 2011
Is this a simple script, or a program with functions? If you have functions, then your x and y probably aren't seen in some other function than where you first used it. See the FAQ for how to get your x and y to be seen where you need them to be seen. http://matlab.wikia.com/wiki/FAQ#How_can_I_share_data_between_callback_functions_in_my_GUI.3F
If you have a simple script, then I don't see any reason why x and y aren't seen everywhere in your script, unless you cleared them.
Ver también
Categorías
Más información sobre Creating, Deleting, and Querying Graphics Objects en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!