Click here to Skip to main content
15,885,537 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
This is my first time doing matlab and I've never coded before. This was a compulsory Uni paper that I have had to take. Prior to this task I've managed to complete various other tasks but this is challenging me beyond what I've learned in the last three weeks.
This is what ive got down so far in my script file inroder to attempt to solve this problem.

function [Points] = SelectKRandomPoints (Image, K)

Image = imread('logo.jpg') %logo.jpg is the image we are dealing with
Image1 = size(Image) %This will give the size on the Image 256 x 102 x 3

This is all I understand and I dont even know if its the correct way to start. What I dont know how to do is to select a bunch of random numbers form the image size matrix. I also dont understand how to write such a code that if I input 'k' to be 5 in my function I will have 5 rows and 2 columns of random numbers.

If you could help it would be great! :) P.S. I dont want answers, just advice/guidance


SelectKRandomPointsPurpose generates a list of k randomly selected pixelsfrom an image.
Input(s)It takes twoinputs in the following order:

1)A 3D image array from which to select points from
2)The number of points to randomly selectOutput(s)

It returns a singleoutput, a 2D array, containing k rows and 2 columns, representing k randomly selected points (pixels).

Example :
Here are some examples of calls to SelectKRandomPoints assuming that A is a 256x256x3 array representing an RGB image,

>> points = SelectKRandomPoints(A,6) points = [150 192 ; 219 40 ; 9 37 225 ; 154 103 ; 65 ; 10 40 ]

What I have tried:

function [Points] = SelectKRandomPoints (Image, K)

Image = imread('logo.jpg') %logo.jpg is the image we are dealing with
Image1 = size(Image) %This will give the size on the Image 256 x 102 x 3
Posted
Updated 22-Aug-18 19:13pm
v2
Comments
Patrice T 22-Aug-18 23:10pm    
Do not Repost questions.
Use Improve question to update your question.

1 solution

So, you show no attempt to solve the problem yourself, you have no question, you just want us to do your HomeWork.
HomeWork problems are simplified versions of the kind of problems you will have to solve in real life, their purpose is learning and practicing.
We do not do your HomeWork.
HomeWork is not set to test your skills at begging other people to do your work, it is set to make you think and to help your teacher to check your understanding of the courses you have taken and also the problems you have at applying them.
Any failure of you will help your teacher spot your weaknesses and set remedial actions.
Any failure of you will help you to learn what works and what don't, it is called 'trial and error' learning.
So, give it a try, reread your lessons and start working. If you are stuck on a specific problem, show your code and explain this exact problem, we might help.

As programmer, your job is to create algorithms that solve specific problems and you can't rely on someone else to eternally do it for you, so there is a time where you will have to learn how to. And the sooner, the better.
When you just ask for the solution, it is like trying to learn to drive a car by having someone else training.
Creating an algorithm is basically finding the maths and make necessary adaptation to fit your actual problem.
 
Share this answer
 
Comments
Member 13958396 22-Aug-18 23:18pm    
`That is not the case, i have no idea where to start and would appreciate some advice
:)
Patrice T 22-Aug-18 23:27pm    
First step learn MathLab.
Second step find documentation about the function you want to make.
Member 13958396 23-Aug-18 0:10am    
Hi maybe I did not make it clear in my question. This is my first time doing matlab and I've never coded before. This was a compulsory Uni paper that I have had to take. Prior to this task I've managed to complete various other tasks but this is challenging me beyond what I've learned in the last three weeks.
This is what ive got down so far in my script file inroder to attempt to solve this problem.

function [Points] = SelectKRandomPoints (Image, K)

Image = imread('logo.jpg') %logo.jpg is the image we are dealing with
Image1 = size(Image) %This will give the size on the Image 256 x 102 x 3

This is all I understand and I dont even know if its the correct way to start. What I dont know how to do is to select a bunch of random numbers form the image size matrix. I also dont understand how to write such a code that if I input 'k' to be 5 in my function I will have 5 rows and 2 columns of random numbers.

If you could help it would be great! :) P.S. I dont want answers, just advice/guidance
Patrice T 23-Aug-18 0:53am    
Use Improve question to update your question.
So that everyone can pay attention to this information.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900