Question

Complete the Logic section of the below MATLAB code to detect the pattern shown where a single pixel/element is EITHER RED or
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Here is the complete code for the following question. if you have any doubt pleae feel free to ask

Code:

clear; clc

counter = 0;

for x = 1: 15

for y = 1: 15

A(x, y) = randi(4) - 1;

end

end

mycolormap = [ 0 0 1;

0 1 0;

1 0 0;

1 0 1 ];

colormap(mycolormap)

for m= 1: 15

for n = 1 : 15

if A(m, n) == 3 || A(m, n) == 1

counter = counter + 1;

end

end

end

fprintf('In A there are %d pixels that are red or green', counter);

In A there are 121 pixels that are red or green

imagesc(A)

---------------------------------------------------------------------------------------------------

Screenshots:

1 O; N 3 clear; clc counter for x = 1: 15 1: 15 A(x, y) = randi(4) - 1; end end 4. 5 for y 09 7 8 9 mycolormap [001; 010; 10024 fprintf(In A there are %d pixels that are red or green, counter); In A there are 121 pixels that are red or green images

Add a comment
Know the answer?
Add Answer to:
Complete the Logic section of the below MATLAB code to detect the pattern shown where a...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Hello, i have this matlab code where i have to track a red ball from and...

    Hello, i have this matlab code where i have to track a red ball from and uploaded video, and plot its direction in x-y direction My Question is how can i add x vs time plot and y vs time plot in this code. Thank you if exist('V','var') delete(V); end clear;clc; V=VideoReader('video.mp4'); figure(1); x=[];y=[]; i=1; while hasFrame(V) J=readFrame(V); figure(1);imshow(J);title(['Frame No. ',num2str(i)]); if (i>=28 && i<=132) bw=J(:,:,1)>200 & J(:,:,2)<80 & J(:,:,3)<80; bw=imfill(bw,'holes'); A=regionprops(bw,'Centroid'); x(end+1)=A.Centroid(1); y(end+1)=A.Centroid(2); hold on; plot(x,y,'*k');hold off; end i=i+1;...

  • ------------------------------------------------------------------------------------------------------------ CODE ALREADY HAVE BELOW--------------------------------------------------------------------------------------- public class LinkedQueue<T>

    ------------------------------------------------------------------------------------------------------------ CODE ALREADY HAVE BELOW--------------------------------------------------------------------------------------- public class LinkedQueue<T> implements QueueADT<T> {    private int count;    private LinearNode<T> head;    private LinearNode<T> tail;               public LinkedQueue()    {        count = 0;        head = null;        tail = null;    }    @Override    public void enqueue(T element)    {        LinearNode<T> node = new LinearNode<T> (element);        if(isEmpty())            head = node;        else           ...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT