hello using this code:
I1 = imread('E:\Dropbox\Andrea VMS\Esame_di_Stato\Programmi\Spur_Gear\Spur11.PNG');
imshow(I1);
Y_j=input('Insert the geometrical coefficient of flexural resistance: ');
close
appears a black window. using other images i have no problem. this is an image i scanned from a book

2 件のコメント

Geoff Hayes
Geoff Hayes 2016 年 3 月 8 日
Andrea - what are the dimensions of I1 and what is its data type? For example, what does the following return
class(I1)
andrea vironda
andrea vironda 2016 年 3 月 8 日
hi Geoff. this is uint8, and also the not working one

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

 採用された回答

Image Analyst
Image Analyst 2016 年 3 月 8 日

0 投票

Try
imshow(I1, []);
message = sprintf('Max Value = %f\nMin Value = %f\n', max(I1(:)), min(I1(:)))
uiwait(helpdlg(message));
Also, check the values of I1 in the variable editor to see what they are.

3 件のコメント

andrea vironda
andrea vironda 2016 年 3 月 8 日
編集済み: Image Analyst 2020 年 3 月 5 日
Using
imshow(I1, []);
I can see the image, good!
In the help dialog I see
message =
Max Value = 1.000000
Min Value = 0.000000
Image Analyst
Image Analyst 2016 年 3 月 8 日
Glad that solved it. Maybe you could go ahead and "Accept this answer".
Ammon McCarthy
Ammon McCarthy 2020 年 3 月 5 日
thank you

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

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2016 年 3 月 8 日

0 投票

The PNG image might not be in RGB form. In particular it might be in indexed form, or it might be in grayscale. You should use the two-output form of imread() if it is an indexed image, and you should use colormap(gray(256)) if it is grayscale.

3 件のコメント

andrea vironda
andrea vironda 2016 年 3 月 8 日
編集済み: andrea vironda 2016 年 3 月 8 日
yes, i scanned the paper from paint using greyscale. were can i put colormap(gray(256))?
Mats Burgmans
Mats Burgmans 2018 年 5 月 23 日
can you still answer the question Walter Robertson?
Image Analyst
Image Analyst 2018 年 5 月 24 日
You call that right after you call imshow() to display the image. Here's some snippets:
[imageArray, colorMap] = imread(fullImageFileName);
% colorMap will have something for an indexed image (gray scale image with a stored colormap).
% colorMap will be empty for a true color RGB image or a monochrome gray scale image.
% Here we actually display the image in the "axesImage" axes.
imshow(imageArray, 'InitialMagnification', 'fit', 'parent', handles.axesImage);
[rows, columns, numberOfColorChannels] = size(imageArray);
% Get the file date
fileInfo = dir(fullImageFileName);
txtInfo = sprintf('%s\n\n%d lines (rows) vertically\n%d columns across\n%d color channels\n', ...
[basefilename extension], rows, columns, numberOfColorChannels);
% Tell user the type of image it is.
if numberOfColorChannels == 3
colorbar 'off'; % get rid of colorbar.
txtInfo = sprintf('%s\nThis is a true color, RGB image.', txtInfo);
elseif numberOfColorChannels == 1 && isempty(colorMap)
colorbar 'off'; % get rid of colorbar.
txtInfo = sprintf('%s\nThis is a gray scale image, with no stored color map.', txtInfo);
elseif numberOfColorChannels == 1 && ~isempty(colorMap)
txtInfo = sprintf('%s\nThis is an indexed image. It has one "value" channel with a stored color map that is used to pseudocolor it.', txtInfo);
colormap(colorMap);
whos colorMap;
%fprintf('About to apply the colormap...\n');
% Thanks to Jeff Mather at the Mathworks to helping to get this working for an indexed image.
colorbar('peer', handles.axesImage);
%fprintf('Done applying the colormap.\n');
end
uiwait(helpdlg(txtInfo));
Adapt as needed for your program.

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

カテゴリ

Community Treasure Hunt

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

Start Hunting!

Translated by