Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/image/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/matlab/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Image 如何在图形用户界面matlab中浏览图像并在显示到轴之前对其进行处理_Image_Matlab_User Interface_Processing_Axes - Fatal编程技术网

Image 如何在图形用户界面matlab中浏览图像并在显示到轴之前对其进行处理

Image 如何在图形用户界面matlab中浏览图像并在显示到轴之前对其进行处理,image,matlab,user-interface,processing,axes,Image,Matlab,User Interface,Processing,Axes,我想用matlab创建一个GUI,浏览图像并在将其显示到某些轴之前对其进行处理 我无法使用当前程序浏览图像,并且我要显示的图像与上一个进程相关。是否可以仅用一个按钮浏览并将所有处理过的图像显示到轴上?有人能帮我创建这个示例程序的GUI吗 folder = 'D:\wildlife'; baseFileName = 'page-6.png'; fullFileName = fullfile(folder, baseFileName); % Get the full filenam

我想用matlab创建一个GUI,浏览图像并在将其显示到某些轴之前对其进行处理

我无法使用当前程序浏览图像,并且我要显示的图像与上一个进程相关。是否可以仅用一个按钮浏览并将所有处理过的图像显示到轴上?有人能帮我创建这个示例程序的GUI吗

folder = 'D:\wildlife';
   baseFileName = 'page-6.png';
   fullFileName = fullfile(folder, baseFileName);
   % Get the full filename, with path prepended.
   fullFileName = fullfile(folder, baseFileName);
   if ~exist(fullFileName, 'file')
    % Didn't find it there.  Check the search path for it.
    fullFileName = baseFileName; % No path this time.
    if ~exist(fullFileName, 'file')
        % Still didn't find it.  Alert user.
        errorMessage = sprintf('Error: %Gambar tidak ditemukan.', fullFileName);
        uiwait(warndlg(errorMessage));
        return;
    end
end
rgbImage = imread(fullFileName);

% Get the dimensions of the image.  numberOfColorBands should be = .
[rows columns numberOfColorBands] = size(rgbImage);

% Display the original color image.
subplot(2, 3,  1);
imshow(rgbImage);
title('Gambar Asli', 'FontSize', fontSize);

% Enlarge figure to full screen.
set(gcf, 'units','normalized','outerposition',[0 0 1 1]);

%set the morphology
SE = strel ('square', 3);
 j=imerode (rgbImage, SE);
subplot(2, 3,  2);
imshow(j);
title('Penebalan Citra', 'FontSize', fontSize);

% Binarize to find black pixels
% Find where either red, green, or blue channel is dark.
thresholdValue = 55;
binaryImage = j(:,:, 1) < thresholdValue | j(:,:, 2) < thresholdValue | j(:,:, 3) < thresholdValue;

% Display the image.
subplot(2, 3,  3);
imshow(binaryImage);
title('Citra Biner', 'FontSize', fontSize);

% Fill the image
filledImage = imfill(binaryImage, 'holes');
% Display the image.
subplot(2, 3,  4);
imshow(filledImage);
title('Pengisian Citra Biner', 'FontSize', fontSize);
drawnow;

为了创建GUI,Matlab的GUIDE特性有很好的文档记录,并且相对容易使用和学习。只需在Matlab提示符下键入“guide”即可调出快速启动菜单

创建一个新的空白GUI后,可以添加一个按钮和任意多个轴,以显示上面示例代码的各种图像4。然后,浏览、处理和显示图像的代码可以放在按钮的回调中。要打开回调代码,右键单击按钮并从菜单中选择View Callbacks->callback

然后,您可以使用以下内容浏览所需图像:

[baseFileName, folder, FilterIndex] = uigetfile('*.png');
要在所需轴中显示图像,请在对“imshow”的调用中指定适当的轴句柄作为“Parent”参数,而不是使用“subplot”:

% Display the original color image.
fullFileName = [folder baseFileName];
rgbImage = imread(fullFileName);
imshow(rgbImage, 'Parent', handles.axes1);