How to store the gray level pixel values into a 2-D array?
2 ビュー (過去 30 日間)
古いコメントを表示
In MATLAB,images are stored in a 1-D array....how to put them into a 2-D array?
2 件のコメント
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.
採用された回答
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 件)
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 件のコメント
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 Center および File 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!