to make 5 image to be an unit using histogram

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

Please explain better. What does the histogram have to do with anything? What is "an unit"? Do you mean a single variable, such as a cell array? If so, then what is wrong with the way you did it?
Do you mean that you want to use the images as what is drawn for the histogram instead of bars? The way sometimes magazines illustrate using (for example) stacks of '$' signs?
$
$ $
$ $ $
$ $ $
yes, i mean is 5 grayscale images into a single variable. My code:
for i = 1:5
citra1{i} = imread(['D:imageGray\' num2str(i) '.jpg']);
end
%for single variable
OneCitra=([citra3{1} citra3{2} citra3{3} citra3{4} citra3{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'));
and error:
??? Error using ==> horzcat CAT arguments dimensions are not consistent.
Error in ==> ekstrasi_ciri_histo>axes47_CreateFcn at 312
OneCitra=([citra1{1} citra1{2} citra1{3} citra1{4} citra1{5}]);
Error in ==> gui_mainfcn at 96 feval(varargin{:});
Error in ==> ekstrasi_ciri_histo at 42 gui_mainfcn(gui_State, varargin{:});
Error in ==> @(hObject,eventdata)ekstrasi_ciri_histo('axes47_CreateFcn',hObject,eventdata,guidata(hObject))
??? Error using ==> struct2handle Error while evaluating axes CreateFcn
if I find a histogram with the code as it is true? because when the dimensions of the image is the same, the code runs fine.
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.
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'));

댓글을 달려면 로그인하십시오.

 채택된 답변

Walter Roberson
Walter Roberson 2013년 1월 15일

1 개 추천

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

i'm sorry. i make mistake on copy - paste. and thank you WR. can you explain me about this?
[citra1{1}(:); citra1{2}(:); citra1{3}(:); citra1{4}(:); citra1{5}(:)]
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.
thank you, i understand now. your code running my program.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Image Analyst
Image Analyst 2013년 1월 15일

1 개 추천

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).

카테고리

도움말 센터File Exchange에서 Data Distribution Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by