필터 지우기
필터 지우기

Hi, I want a 2d array of rows and columns filled with floating point numbers (matrix) which can be converted to a grayscale image.

조회 수: 4 (최근 30일)
Should i use the mat2gray function of matlab ? I want to program my own image and fill it with numbers.
  댓글 수: 4
Walter Roberson
Walter Roberson 2016년 2월 25일
repmat(A,B,C) makes B vertical copies and C horizontal copies. When A is a row vector that means you would end up with B rows.
Anvinder  Singh
Anvinder Singh 2016년 2월 25일
Thanks Walter. So is it possible to use multiple loops in the same matrix to have different pixels ? I mean instead of one repmat i need multiple repmats for the same matrix A.

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

답변 (1개)

Cam Salzberger
Cam Salzberger 2016년 2월 29일
Hello Anvinder,
I understand that you are looking to display a grayscale image based on values from a matrix. As jgg said, "mat2gray" helps in ensuring that the matrix values get scaled appropriately (between 0 and 1) to display the full range in an image.
You don't need to use "repmat" to create the grayscale image, that was just an example. Here's an example that uses loops to allow for calculating each pixel value:
nRows = 10;
nCols = 15;
A = zeros(nRows,nCols);
for r = 1:nRows
for c = 1:nCols
A(r,c) = r+c/2;
end
end
I = mat2gray(A);
imshow(I)
I hope this helps!
-Cam

카테고리

Help CenterFile Exchange에서 Images에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by