Write a function to show a square “random” image. The function will take in “at least” one input argument which is the size of the image in pixels. As a default, the image will be shown in black-white. If a second input argument is provided, it will
Mostrar comentarios más antiguos
This is what I have so far:
function week7hw1(pixels, varargin)
%This function will receive the size of the pixels as an input
%if a second input is entered, the image will be the colormap
n=nargin;
mat=randi(pixels);
if n==0
image(mat)
elseif n==1;
colormap(varargin)
image(mat)
end
end
I'm not sure what I am doing wrong for this function.
Respuesta aceptada
Más respuestas (1)
KALYAN ACHARJYA
el 21 de Jul. de 2019
Editada: KALYAN ACHARJYA
el 21 de Jul. de 2019
function image1=rand_image()
pixel_num=input('Enter the value ');
image1=logical(randi(2,[pixel_num pixel_num])-1); %@Image Analyst Answer
imshow(image1);
end
Command Window:
>> y=rand_image();
Enter the value 100
Figure Window:

Second Part is not complete-
If a second input argument is provided, it will
3 comentarios
Caitlin Schmidt
el 21 de Jul. de 2019
KALYAN ACHARJYA
el 21 de Jul. de 2019
Editada: KALYAN ACHARJYA
el 21 de Jul. de 2019
function image1=rand_image(pixel_num)
image1=logical(randi(2,[pixel_num pixel_num])-1); %@Image Analyst Answer
imshow(image1);
end
Now pass the pixel value from here
y=rand_image(100)
Caitlin Schmidt
el 21 de Jul. de 2019
Editada: Caitlin Schmidt
el 21 de Jul. de 2019
Categorías
Más información sobre Color and Styling en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!