フィルターのクリア

Hello Everyone, How can I check if someone uploads a video in MATLAB GUI using browse button instead of uploading an image?

2 ビュー (過去 30 日間)
Hello Everyone, How can I check if someone uploads a video in MATLAB GUI using browse button instead of uploading an image? I am developing tool for image processing and I want to apply a check on the browse button so whenever the end user try to upload a video, it will show an error message.
  4 件のコメント
Rik
Rik 2020 年 4 月 19 日
You can use fileparts to extract the extension and compare it to the list of extensions imread supports. I don't have a suggestion for how you could generate a list of video formats, but if you just want to throw an error when the user doesn't select an image, this strategy should work for you.

サインインしてコメントする。

回答 (2 件)

Walter Roberson
Walter Roberson 2020 年 4 月 19 日
Use try/catch on the imread. When the imread fails use try/catch on imfinfo; if it succeeds it was video (or possibly audio in container) and if it fails the file was not image or video.
  2 件のコメント
Walter Roberson
Walter Roberson 2020 年 4 月 19 日
caution: Support for some formats is based on the contents of the file, not on the file extension. On some platforms if you rename an image file to the wrong extension then the code will detect the correct format instead of relying on the extension

サインインしてコメントする。


Mehmed Saad
Mehmed Saad 2020 年 4 月 19 日
編集済み: Mehmed Saad 2020 年 4 月 19 日
Try this
[Filename,Pathname] =uigetfile(...
{'*.png','PNG (*.png)';
'*.tif;*.tiff','TIFF (*.tif,*.tiff)';
'*.gif','GIF (*.gif)';
'*.jpg;*.jpeg;*.jpe;*.jfif','JPEG (*.jpg,*.jpeg,*.jpe,*.jfif)';
'*.bmp','BMP (*.bmp)';},'File Selector')
He can only select these types of file and is not possible for him select any other file
Also you can go with this too
[Filename,Pathname] =uigetfile(...
{'*.png;*.jpg;*.jpeg;*.jpe;*.jfif;*.tif;*.tiff;*.gif;*.bmp',...
'Image File(*.png,*.jpg,*.jpeg,*.jpe,*.jfif,*.tif,*.tiff,*.gif,*.bmp)'},'File Selector');
  5 件のコメント

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeDesktop についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by