필터 지우기
필터 지우기

How to set units of image of an array to pixels?

조회 수: 2 (최근 30일)
Anna
Anna 2014년 8월 9일
댓글: Anna 2014년 8월 18일
I have a matrix (called V) of 1000*1000 random 0s and 1s. I want each 0 or 1 to be represented by a single pixel on the screen.
The command imagesc(V) makes each 0 or 1 a square which black(0) or white(1), how do I make each rectangle one pixel?
(I have made a color map for this, MAP = [0 0 0; 1 1 1]. If there was an easier way to make 0s appear black and 1s appear white, please let me know).

채택된 답변

Matz Johansson Bergström
Matz Johansson Bergström 2014년 8월 9일
편집: Matz Johansson Bergström 2014년 8월 9일
I believe you are looking for
truesize(gcf, [1000 1000])
  댓글 수: 2
Image Analyst
Image Analyst 2014년 8월 9일
That's fine if your figure only has one axes in it that takes up the whole figure. But what if you have 2 or 3 images on a figure. How do you set up one of them to be unit magnification?
bigImage = imread('concordorthophoto.png');
[rows, columns, numberOfColorChannels] = size(bigImage);
% First create some figure.
figure;
% Now create an axes in the upper left:
hAxes = subplot(2, 2, 1);
% Display the image in that axes
imshow(bigImage, 'InitialMagnification','fit')
cla reset;
imshow(bigImage, 'InitialMagnification', 100); % Doesn't work either
% Resize image to show image at its rows-by-column pixel size,
% one image pixel equals one screen pixel.
% Since the image is bigger than the axes, it should add scrollbars.
truesize(hAxes, [rows, columns])
Anna
Anna 2014년 8월 18일
I entered the following commands:
V = zeros(100); image(V); truesize(gcf, [100 100])
The resolution (in pixels/cm) of my screen is 51.6 pixels per cm. This means that the image of the array should be 100/51.6 = 1.94 cm wide, if each element is actually corresponding to one pixel. However, the image was 2.9cm wide. Any suggestions for how I can create an image of a matrix such that each element is exactly one pixel, as I still haven't managed to do this?
(I calculated the resolution (51.6 pixels per cm) using physical measurements of the screen, and the fact that it is 1600 by 900 pixels. I also tried this, http://www.mathworks.com/matlabcentral/answers/100792-in-matlab-how-do-i-obtain-information-about-my-screen-resolution-and-screen-size , after changing "inches" to "centimeters", but the values for screensize were wrong, both in cm and pixels, and the resolution was given as 37.8 in both directions, which doesn't agree with my calculation.).

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

태그

Community Treasure Hunt

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

Start Hunting!

Translated by