How to take Image as Input in a function

조회 수: 72 (최근 30일)
Talal Waseem
Talal Waseem 2020년 3월 31일
댓글: Ella 2023년 6월 6일
Im trying to make a function that takes a image of any type (png,jpeg etc) and then performs some task on them. But i cannot figure how to take the image as input in the function. Please help :)

답변 (2개)

Cris LaPierre
Cris LaPierre 2020년 3월 31일
You'd have to first load the image into MATLAB and store it in a variable. You can then pass that variable as input to your function.
Here's the link to a doc page on importing images.
  댓글 수: 5
Ella
Ella 2023년 6월 5일
I also made sure that the image is downloaded into the proper file
Cris LaPierre
Cris LaPierre 2023년 6월 5일
편집: Cris LaPierre 2023년 6월 5일
Share the code you have written (including loading your image) that calls/uses your function.

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


Image Analyst
Image Analyst 2023년 6월 6일
For example
grayImage = imread('moon.tif');
meanGL = mean2(grayImage)
meanGL = 52.9154
grayImage2 = DarkenImage(grayImage); % Call function
meanGL2 = mean2(grayImage2)
meanGL2 = 26.7118
%======================================================
% Define function that divides the image values by 2
function output = DarkenImage(inputImageArray)
output = inputImageArray / 2;
end
  댓글 수: 1
Ella
Ella 2023년 6월 6일
I managed to figure it out! Thank you for your help

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

카테고리

Help CenterFile Exchange에서 Image Segmentation and Analysis에 대해 자세히 알아보기

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by