i have 10 folders and in each folder i have 20 images...for a folder i need to extract histogram normalization values of images and i need to store them for further use...i have written code but im unable to get stored values...help me ..thanks

clear all;
close all;
Folder='G:\C\New folder (2)\(2)';
file1=fullfile(Folder,'*.png');
pngimages1=dir(file1);
numOfFiles=length(pngimages1);
for i=1:length(pngimages1)
FileName1=pngimages1(i).name;
fullFileName1=fullfile(Folder,FileName1);
im1=imread(fullFileName1);
im11=rgb2gray(im1);
im111=imhist(im11)./numel(im11);
im112=im111(i,:);
end
xlswrite('myFile.xlsx',im112);

 Accepted Answer

Do you mean
im112(i,:) = im111;
instead of
im112=im111(i,:);

7 Comments

tried that too sir..im112(i,:) = im111; getting all cells '0' in excel sheet
im112(i,:) = im111; giving empty excel sheet sir.
Someone help me how to save those features for further use
@Gohan: Sorry, you do not provide enough information to understand your problem. You did not explain, what the code should do and useful comments are also missing.
The explanation "all cells '0'" and "empty excel sheet" are contradictions. Please post exactly, what happens. Do not let us guess the details.
Perhaps you obtain the images in UINT8 format. Then the division might not give the expected results. Try this:
numOfFiles=length(pngimages1);
for i=1:length(pngimages1)
FileName1 = pngimages1(i).name;
fullFileName1 = fullfile(Folder,FileName1);
im1 = imread(fullFileName1);
im11 = rgb2gray(im1);
im111 = double(imhist(im11)) ./ numel(im11);
im112(i,:) = im111;
end
xlswrite('myFile.xlsx',im112);
Set a breakpoint in the "im111 = ..." line and check the output manually in the CommandWindow.
"im1", "im11", "im111" are ugly names. What about "img", "imgGrey" and "normHist"?
Sorry sir ... My task is ..i have 10 folders and in each folder i have 50 images of same object with small change .. I have to extract features of each folder of images (like ..histogram normalization values) and I have to save those features ..
In final step i have to use these features for training and testing neural network ..
The above code i have written is to take histnorm values for 1st folder images ....
And names im11 and im111 sry for confusing just written without thinking of names
@Gohan: Okay. Then what exactly is your question? Creating a loop over the folders? Before I could suggest some code for this, you have to explain, how the set of folders is recognized. Perhaps all subfolders of a specific base folder?
FolderList = dir(BaseFolder);
FolderList = FolderList([FolderList.isdir]);
FolderName = fullfile(BaseFolder, {FolderList.name});
Then run a loop over the folders.
Please explain "but im unable to get stored values" with any details. It is much easier to fix a problem than to guess what the problem is.
I don't even know what "histogram normalization values" are. Please explain in detail. The histogram() function can return 'pdf' and 'probability' versions of the histogram, if that's what you want - see its options.

Sign in to comment.

More Answers (0)

Products

Asked:

on 25 Jul 2017

Commented:

on 27 Jul 2017

Community Treasure Hunt

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

Start Hunting!