From: david carollo on
ImageAnalyst <imageanalyst(a)mailinator.com> wrote in message <c0b1c8ac-a017-4c7e-a2d6-fe9cd567296e(a)n15g2000yqf.googlegroups.com>...
> On May 6, 7:52 pm, "david carollo" <xdav...(a)gmail.com> wrote:
> > Ps:Why blockproc Read/Write File Formats: TIFF ?
> > My images are Jpg..need to transform?
> ------------------------------------------------------------------------------------
> I don't know but it doesn't matter. Just read in your image with
> imread, like this example in the help for blockproc() where they did
> it for a PNG format image:
>
> I = imread('pears.png');
> I2 = blockproc(I,[100 100],fun);


Yes I try it but have only a resize of the image..I read a lot of help pages but I cannot find a function to subdivide my images, to

I find an interesting function called quadtree decomposition

This is an example:
I = imread('liftingbody.png');
S = qtdecomp(I,.27);
blocks = repmat(uint8(0),size(S));

for dim = [512 256 128 64 32 16 8 4 2 1];
numblocks = length(find(S==dim));
if (numblocks > 0)
values = repmat(uint8(1),[dim dim numblocks]);
values(2:dim,2:dim,:) = 0;
blocks = qtsetblk(blocks,S,dim,values);
end
end

blocks(end,1:end) = 1;
blocks(1:end,end) = 1;

imshow(I), figure, imshow(blocks,[])

I don't know if I can use that in my program, but it is very good because divide the image about the omogeneity of the image areas..

What do you think about?

t's cool but I think it's also good a normal grid..but how I can draw it?

Have a nice day...
From: ImageAnalyst on
david:
No. You don't need to complicate it like that. Just use blockproc to
compute your HSV means in steps (tiles). Then look up the values in
your database to see which ones are closest.

The way you might scan your set of images to get their mean hsv values
(which you will store in your database) is something like this:
(Be sure to join any lines broken into two by the newsreader)


% function rgb2hsv_Demo()

% 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;

% Create a figure for our images.
figure;
set(gcf, 'Position', get(0,'Screensize')); % Maximize figure.

% Read in standard MATLAB color demo images.
imagesFolder = 'C:\Program Files\MATLAB\R2010a\toolbox\images
\imdemos';
filePattern = [imagesFolder, '\*.jpg'];
% Read the directory to get a list of images.
jpegFiles = dir(filePattern);
numberOfImagesProcessed = 0;
numberOfImagesToProcess = length(jpegFiles);
% Loop though all images, converting to hsv and then getting the means
% of the h, s, and v channels.
hImage_Mean = zeros(numberOfImagesToProcess, 1);
sImage_Mean = zeros(numberOfImagesToProcess, 1);
vImage_Mean = zeros(numberOfImagesToProcess, 1);
for k = 1 : numberOfImagesToProcess
% Read in this one file.
baseFileName = jpegFiles(k).name;
fullFileName = fullfile(imagesFolder, baseFileName);
rgbImage = imread(fullFileName);
subplot(2, 3, 1);
imshow(rgbImage, []);
title('Original color Image', 'FontSize', fontSize);

% Convert to floating point so it does the calculations correctly.
% Also needs to be normalized to 0-1.
rgbFloating = double(rgbImage) / 255.0;

% Resize it to be 32 pixels by 32 pixels.
rgbFloating = imresize(rgbFloating, [32 32]);
subplot(2, 3, 2);
imshow(rgbFloating, []); % Display the image.
title('Scaled down 32x32 color Image', 'FontSize', fontSize);

% Compute hsv image
hsvImage = rgb2hsv(rgbFloating);
% H image:
hImage = hsvImage(:,:,1);
subplot(2, 3, 4);
imshow(hImage, []); % Display the image.
% Compute mean
hImage_Mean(k) = mean(hImage(:));
caption = sprintf('H Image. Mean = %6.2f', hImage_Mean(k));
title(caption, 'FontSize', fontSize);

% S image:
sImage = hsvImage(:,:,2);
subplot(2, 3, 5);
imshow(sImage, []); % Display the image.
% Compute mean
sImage_Mean(k) = mean(sImage(:));
caption = sprintf('S Image. Mean = %6.2f', sImage_Mean(k));
title(caption, 'FontSize', fontSize);

% V image:
vImage = hsvImage(:,:,3);
subplot(2, 3, 6);
imshow(vImage, []); % Display the image.
numberOfImagesProcessed = numberOfImagesProcessed + 1;
% Compute mean
vImage_Mean(k) = mean(vImage(:));
caption = sprintf('V Image. Mean = %6.2f', vImage_Mean(k));
title(caption, 'FontSize', fontSize);

% Prompt user to continue.
promptMessage = sprintf('Currently displaying image #%d of %d:\n%s
\nDo you want to Continue processing,\nor Cancel to abort
processing?',...
numberOfImagesProcessed, numberOfImagesToProcess, baseFileName);
button = questdlg(promptMessage, 'Continue', 'Continue', 'Cancel',
'Continue');
if strcmp(button, 'Cancel')
break;
end

end
% Crop off any unassigned values:
hImage_Mean = hImage_Mean(1:numberOfImagesProcessed);
sImage_Mean = sImage_Mean(1:numberOfImagesProcessed);
vImage_Mean = vImage_Mean(1:numberOfImagesProcessed);

% Print to command window
fprintf(1, ' Filename, H Mean, S Mean, V Mean\n');
for k = 1 : length(hImage_Mean)
baseFileName = jpegFiles(k).name;
fprintf(1, '%24s %6.2f, %6.2f, %6.2f\n', ...
baseFileName, hImage_Mean(k), sImage_Mean(k), vImage_Mean(k));
end

caption = sprintf('Done with demo!\n\nProcessed %d images.\nCheck out
the command window for the results', numberOfImagesProcessed);
msgbox(caption);



From: david carollo on
??? Error: File: provamosaico.m Line: 81 Column: 25
A MATLAB string constant is not terminated properly.

( promptMessage = sprintf('Currently displaying image #%d of %d:\n%s )

Ps:thank U!
From: dpb on
david carollo wrote:
> ??? Error: File: provamosaico.m Line: 81 Column: 25
> A MATLAB string constant is not terminated properly.
>
> ( promptMessage = sprintf('Currently displaying image #%d of %d:\n%s )
>
> Ps:thank U!

You didn't take care of line wrap in IA's previous posting (nor pay much
attention to what you were doing, either, apparently)

This is the original line -- it's wrapped a couple of times from cutting
and pasting but to straighten it out is an exercise left for the student...

> % Prompt user to continue.
> promptMessage = sprintf('Currently displaying image #%d of %d:\n%s
> \nDo you want to Continue processing,\nor Cancel to abort
> processing?',...
> numberOfImagesProcessed, numberOfImagesToProcess, baseFileName);

--
From: ImageAnalyst on
Yes. The newsreader does that (like I said) so be careful about that,
because so many people aren't ;-)
In fact, that's why I explicitly put in this statement:
(Be sure to join any lines broken into two by the newsreader)

You can see I tried to continue lines with the ... statement. However
MATLAB does not allow that within literal strings (the single
quotes). Even in non-strings, though, the newsreader will still break
it at 80 characters or so regardless of what you do (as far as I know
though maybe there's a way around it that I'm not aware of).