필터 지우기
필터 지우기

How I can generate an image and modify it with Matlab?

조회 수: 37 (최근 30일)
K. Taieb
K. Taieb 2020년 6월 24일
답변: Image Analyst 2020년 6월 24일
Hello,
Is it possible to generate an image with defined row and column numbers without going through the generation of a 2D matrix.
Usually, I created the image according to the following code :
A=3000*ones(200,200);
imwrite(A,['image' num2str(1) '.jp2']);
I want generate an image with 200 rows and 200 columns without generate the matrix A.
My second question, how can I modify an element (the value of a pixel) of an image?
Thank you!

채택된 답변

Kanika Gupta
Kanika Gupta 2020년 6월 24일
편집: Kanika Gupta 2020년 6월 24일
Try using this to create a blank image of desired size
blankimage=zeros(200,200)
imshow(blankimage)
To change value at specific location simply do
blankimage(1,1)=255
  댓글 수: 2
K. Taieb
K. Taieb 2020년 6월 24일
Thank you!
It is the same problem, when I generate an image with a large matrix, the matrix size exceeds the capacity of my computer. Like in this example:
blankimage=zeros(50000,50000);
imshow(blankimage)
Kanika Gupta
Kanika Gupta 2020년 6월 24일
The maximum size of array supported by Matlab is 10,000. This can be seen
home > preferences > workspace > maximum array size.
If you wish to use it for larger arrays, refer to https://www.mathworks.com/help/matlab/matlab_prog/resolving-out-of-memory-errors.html

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

추가 답변 (1개)

Image Analyst
Image Analyst 2020년 6월 24일
Use the uint16 option in ones to cut down the size by a factor of 4. If you use ones() without it, you're using floating point values and have 8 bytes instead of 2 bytes and uint16.
A = 3000 * ones(200, 200, 'uint16');
imwrite(A, 'image1.jp2');

카테고리

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