필터 지우기
필터 지우기

How to store the gray level pixel values into a 2-D array?

조회 수: 2 (최근 30일)
Durga
Durga 2015년 4월 25일
댓글: Durga 2015년 4월 25일
In MATLAB,images are stored in a 1-D array....how to put them into a 2-D array?
  댓글 수: 2
Stephen23
Stephen23 2015년 4월 25일
편집: Stephen23 2015년 4월 25일
Can you show any documentation that states that "In MATLAB,images are stored in a 1-D array." ?
All the documentation that I have ever read states that images are stored as m*n or m*n*3 arrays:
If you have an image in a "1-D array" then this is certainly not due to using the inbuilt MATLAB image functions, and you will need to show us your code so that we can see what you are doing.
Durga
Durga 2015년 4월 25일
Actually i want to do substract one image from another(substract their pixel values and store them into a 2-D array.And then finding the Median value from the difference matrix. So,at first i was jst storing the value of the images:
val=img1(); val1=img2();
I culd not do it via 2-D operations,so i thought it is done via 1-D operations..

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

채택된 답변

Stephen23
Stephen23 2015년 4월 25일
편집: Stephen23 2015년 4월 25일
If the images are the same size then you can simply subtract the arrays directly:
A = imread(filenameA);
B = imread(filenameB);
D = A-B;
This works because in MATLAB many operations are vectorized, which means they operate on the whole array all at once. If the images are different sizes then you will need to resize one or both of them before performing this subtraction. You could use imresize for this.
And then use median note that the image data is going to be 2D or 3D depending on the image type, so to get the median of all values you will need to convert the array to a vector first:
median(D(:))
  댓글 수: 1
Durga
Durga 2015년 4월 25일
Thanks Sir. using D=A-B is correct for this method and i have got the difference 2-D array.

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

추가 답변 (1개)

Jan
Jan 2015년 4월 25일
No, gray level images are stored in 2D array in Matlab in general.
Please explain, why you assume that they are stored in 1D-vectors. This assumption seems to be the problem.
  댓글 수: 2
Durga
Durga 2015년 4월 25일
편집: Durga 2015년 4월 25일
Actually i want to do substract one image from another(substract their pixel values and store them into a 2-D array.And then finding the Median value from the difference matrix. So,at first i was jst storing the value of the images:
val=img1(); val1=img2();
I culd not do it via 2-D operations,so i thought it is done via 1-D operations..
Jan
Jan 2015년 4월 25일
Please post you code and post a copy of the error messages. It is hard to give a suggestion based on "I could not do it".

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

카테고리

Help CenterFile Exchange에서 Read, Write, and Modify Image에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by