how to convert char array to two dimension image

21 ビュー (過去 30 日間)
sallam tanna
sallam tanna 2016 年 4 月 30 日
コメント済み: sallam tanna 2016 年 5 月 1 日
hello my gui brows an image and I want to apply edge method on this image but the problem that when i brows image it appear as string , so i cant apply edge method?? can anyone tell me how to solve this problem please ?
  2 件のコメント
Walter Roberson
Walter Roberson 2016 年 5 月 1 日
Please post your code.
It sounds like you might be trying to work on the name of the file rather than the content of the file.
sallam tanna
sallam tanna 2016 年 5 月 1 日
編集済み: Walter Roberson 2016 年 5 月 1 日
function brows_Callback(hObject, eventdata, handles)
[filename pathname] = uigetfile({'*.tif'},'File Selector');
image = strcat(pathname, filename);
axes(handles.axes1);
imshow(image)
complete = strcat(pathname,filename);
set(handles.path,'string',complete);
% here the problem.. how can I apply edge method ?
[~, threshold] = edge(image, 'sobel');
fudgeFactor = .5;
BWs = edge(image,'sobel', threshold * fudgeFactor);
axes(handles.axes2);
imshow(BWs)
thank you in advance

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

採用された回答

Walter Roberson
Walter Roberson 2016 年 5 月 1 日
  1. Do not name a variable image
  2. You need to read the content of the image file using imread()
  3. It is recommended to use fullfile() to construct the file names instead of strcat
  2 件のコメント
sallam tanna
sallam tanna 2016 年 5 月 1 日
function brows_Callback(hObject, eventdata, handles)
[filename pathname] = uigetfile({'*.tif'},'File Selector');
img = strcat(pathname, filename); axes(handles.axes1); imshow(img) complete = fullfile(pathname,filename); set(handles.path,'string',complete); X = imread(img);
% the same error here [~, threshold] = edge(X, 'sobel');
the same problem ! :(
sallam tanna
sallam tanna 2016 年 5 月 1 日
I solve the problem finally
this is the code
[filename pathname] = uigetfile({'*.tif'},'File Selector'); img = strcat(pathname, filename); axes(handles.axes1); imshow(img) complete = fullfile(pathname,filename); set(handles.path,'string',complete);
X = imread(img); X = rgb2gray(X); % to convert the image to two dimensional in order to use edge method
thank you for helping ^_^

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by