現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
古いコメントを表示
0 投票
Hi, I have some pictures, some of them are 2D and some are 3D. I need to convert 2D to 3D if I choose to open 2D picture( because I use histeq and imhist) I don´t know how to do write a command for converting to 3D if it is needed and not if is choosen 3D picture.
Thanks a lot
jane
p.s: sorry for my english
1 件のコメント
Image Analyst
2013 年 4 月 4 日
histeq() (a pretty much useless function by the way) and imhist() require 2D (grayscale) images, not 3D (color) images, so why do you want to convert to 3D/color if you say you're going to use histeq() and imhist()???
採用された回答
Walter Roberson
2013 年 4 月 4 日
if ndim(TheArray) == 2
TheArray = TheArray(:,:,[1 1 1]);
end
13 件のコメント
I´m not sure it is correct now, but it doesn´t work so I do something wrong. I have
[file path]=uigetfile({'*.jpg';'*.bmp';'*.jpeg';'*.png'}, 'Načti
obrázek');
image=[path file];
handles.file=image;
if ndim(image) == 2
image = image(:,:,[1 1 1]);
end
handles.imga=im2double(rgb2gray(imread(image)));
and error is : Undefined function 'ndim' for input arguments of type 'char'.
Error in analyza2>pushbuttonload_Callback (line 167) if ndim(image) == 2
Walter Roberson
2013 年 4 月 4 日
I should have suggested ndims() instead of ndim().
However... why are you needing to convert the 2D images to 3D? You would then just use rgb2gray() to convert back down to 2D.
Do not name a variable "image": doing that interferes with using the important image() function.
You should use fullfile() instead of concatenating the path and file.
filename = fullfile(path, file);
handles.file = filename;
imga = imread(filename);
if ndmins(imga) == 3
imga = rgb2gray(imga);
end
imga = im2double(imga);
handles.imga = imga;
janepear
2013 年 4 月 4 日
Thanks a lot...it works great!. Please may I have a one more question? Why I should not use: [file path]=uigetfile({'*.jpg';'*.bmp';'*.jpeg';'*.png'}, 'Načti obrázek'); image=[path file]; ?
Walter Roberson
2013 年 4 月 4 日
The "path" returned by uigetfile() might not include a directory delimiter at the end of it.
Image Analyst
2013 年 4 月 4 日
Now can you answer our question about why you want 3D when imhist and histeq cannot accept 3D images?
janepear
2013 年 4 月 4 日
Ok :-) when I have a all pictures in 3D, I can use rgb2gray and it works for histeq and imhist, but I use colormaps too and they don´t work on 2D (I think). So Ï thought that it will be easier to have all in 3D in one variable and if i need to use histeq or imhist I will transform it.
Sure im beginner and It might by wrong way...
Walter Roberson
2013 年 4 月 4 日
colormaps only work on 2D.
janepear
2013 年 4 月 4 日
Ok so this is weird because it always wrote error
Error using rgb2gray>parse_inputs (line 81) MAP must be a m x 3 array.
Walter Roberson
2013 年 4 月 4 日
If you have a colormapped image that you want to convert to grayscale, use http://www.mathworks.com/help/images/ref/ind2gray.html
Image Analyst
2013 年 4 月 4 日
編集済み: Image Analyst
2013 年 4 月 4 日
You are confused, or I am. If you have grayscale (2D) images, you do not need to make them color (3D) and then use rgb2gray() or some other way to convert them back to grayscale (2D), which is how they started. You're just doing a round trip grayscale->color->grayscale for no reason. You've given us no compelling need why you would need to do that. There's no reason why you can use imhist() and (the useless) histeq() directly on your original grayscale images.
Tell me, in a larger sense or context, what you want to do, and we'll show you how to do it. For example you want to read in all the images in a folder, no matter whether color or grayscale, display their histograms, increase their contrast, and write out the contrast-increased images to a new folder, or something like that. Please give me the big picture (no pun intended) of what this project is supposed to accomplish.
Ok,I´m sure that I´m the confused here :-). So i want to load picture ( 2 or 3D array) and then you can do negativ,contrast,brightness, gamma , equalization or choose in popmenu colormap.
Image Analyst
2013 年 4 月 4 日
This is not the larger picture. What does this code do? Why are you trying to somehow do something with a bone colormap? What do you want as a final image, handles.cm? A color image, an indexed image, or a grayscale image? It looks like a grayscale image so you only need to do that if ndims(handles.imga) == 3. But even if you do it only for color images, I'm not sure why a bone colormap is involved when you end up as grayscale.
1.)I want to show what you can do with utrasound picture...I use colormaps to show that sometimes is better to use copper or summer or another coloration of image
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Images についてさらに検索
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
