saving gray scale images in a 3D array
7 ビュー (過去 30 日間)
古いコメントを表示
I want to save 4 gray scale images in a 3D array and use them. I wrote the following code for this purpose but it did not work!
object_dataset1(:,:,1)=rgb2gray(imread('object1_1.jpg'));
object_dataset1(:,:,2)=rgb2gray(imread('object1_2.jpg'));
object_dataset1(:,:,3)=rgb2gray(imread('object1_3.jpg'));
object_dataset1(:,:,4)=rgb2gray(imread('object1_4.jpg'));
when I use the imshow function to show one of the images it show a white surface!!
for example : imshow(object_dataset1(:,:,2));
0 件のコメント
回答 (1 件)
Cris LaPierre
2019 年 4 月 9 日
Not sure. It works for me.
Check that all your images have the exact same dimensions.
Also, sanity check your code. What happens when you run this?
img = imread('object1_1.jpg')
imshow(img)
img_gr = rgb2gray(imread('object1_1.jpg'))
figure
imshow(img_gr)
object_dataset1(:,:,1)=rgb2gray(imread('object1_1.jpg'));
object_dataset1(:,:,2)=rgb2gray(imread('object1_1.jpg'));
object_dataset1(:,:,3)=rgb2gray(imread('object1_1.jpg'));
object_dataset1(:,:,4)=rgb2gray(imread('object1_1.jpg'));
figure
imshow(object_dataset1(:,:,1))
Note that this actual line of code won't run:
for example : imshow(object_dataset1(:,:,2))
I assume that is just a copy/paste error since otherwise you'd be reporting an error message instead of a white image.
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!