to make 5 image to be an unit using histogram

4 views (last 30 days)
Can help me?
How do I take 5 grayscale images, which have the different size/dimensions, be an unit using histogram?
My image grayscale:
for i = 1:5
citra1{i} = imread(['D:imageGray\' num2str(i) '.jpg']);
end
thank you for help.
  5 Comments
Image Analyst
Image Analyst on 15 Jan 2013
That's not the error for that code. Your code is:
OneCitra=([citra3{1} citra3{2} citra3{3} citra3{4} citra3{5}]);
but the error refers to a citra1, not citra3:
OneCitra=([citra1{1} citra1{2} citra1{3} citra1{4} citra1{5}]);
You have to make sure that when you give an error message you give the actual code that generated the error message.
Dian Permatasari
Dian Permatasari on 15 Jan 2013
i'm sorry IA. i mean:
for i = 1:5
citra1{i} = imread(['D:imageGray\' num2str(i) '.jpg']);
end
%for single variable
OneCitra=([citra1{1} citra1{2} citra1{3} citra1{4} citra1{5}]);
%2D to vektor
foo = reshape((OneCitra),1,numel(OneCitra));
numberOfBins = 256;
foobar = double(foo);
r = hist(foobar,numberOfBins);
plot(r);
save data_r r;
save(fullfile(pwd, 'data_r r'));

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 15 Jan 2013
You cannot construct your OneCitra the way you do if the images do not all have the same number of rows, or do not all have the same third dimension. (Different number of columns would be okay.)
Fortunately you do not need to construct OneCitra. Comment it out and instead use
foo = [citra1{1}(:); citra1{2}(:); citra1{3}(:); citra1{4}(:); citra1{5}(:)];
Note: the code you show does not match your error message. The code you show initializes citra1 but then uses citra3, but your error message uses citra1 as is probably proper.
  3 Comments
Walter Roberson
Walter Roberson on 15 Jan 2013
citra1{1} is your first image. (:) after that reshapes that image to a single column vector. citra1{2} is your second image, the (:) after it reshapes that second image to a single column vector; the ";" between the two parts means to use horizontal concatenation, which would produce a single column vector from the original two.
Dian Permatasari
Dian Permatasari on 15 Jan 2013
thank you, i understand now. your code running my program.

Sign in to comment.

More Answers (1)

Image Analyst
Image Analyst on 15 Jan 2013
The problem is that when you do something like
OneCitra=([citra3{1} citra3{2} citra3{3} citra3{4} citra3{5}]);
you have to make sure that the array inside citra3(1) has the same number of rows as the arrays inside all the other cells. Evidently your images have different sizes. When you use braces like citra3{1}, it means the "contents" of the cell, in other words, the actual array itself contained in the first cell of citra3. If you use parentheses, citra3(1), it means the first cell itself, not the contents of the cell. So citra3(1) is a cell, and citra3{1} is a 2D uint8 matrix (not a cell).

Community Treasure Hunt

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

Start Hunting!