Question

In: Computer Science

1. Create a color image of size 200 × 200. The image should have a blue...

1. Create a color image of size 200 × 200. The image should have a blue background.

2. Create 100 yellow regions within the image that have a variable size. More specifically, their width should be an odd number and vary between 3 and 7 and their height should also be an odd number and vary between 3 and 7. For example, you may get rectangular regions of size 3 × 3, 3 × 5, 5 × 3, 5 × 5, 7 × 5, etc. These 100 yellow regions should be placed at random locations within the 200 × 200 image, but we should make sure that they do not overlap with each other. Important: These regions should be created by modifying the image pixels, and not as plots on top of the image. In other words, these regions should be part of the image.

3. Plot horizontal and vertical white lines on top of the image for every 40 pixel rows and every 40 pixel columns. Now, these white lines will not be part of the image, but an extra layer on top of the image. You may use hold on and hold off, and also plot to achieve this. Display the image with the yellow regions and the white lines in figure(1).

This is what i have for 1 and 2, which is working correctly

clear all;
close all;
clc;

im=zeros(200,200,3);%image
im(:,:,3)=1;
for i=1:100
while true;
  
w=2*round(1+2*rand(1,1))+1;
h=2*round(1+2*rand(1,1))+1;
  
x=round(1+(199-w)*rand(1,100));
y=round(1+(199-h).*rand(1,100));
  
x_dash=x+w;
y_dash=y+h;
  
if all(im(x:x_dash,y:y_dash,2)!=1)
im(x:x_dash,y:y_dash,3)=0;
im(x:x_dash,y:y_dash,1:2)=1;
break;
end
end
end

Need help with Part 3

Solutions

Expert Solution

Following is the complete code in image_yellow_white.m :

clear all;
close all;
clc;

im=zeros(200,200,3);%image
im(:,:,3)=1;
for i=1:100
while true;
  
w=2*round(1+2*rand(1,1))+1;
h=2*round(1+2*rand(1,1))+1;
  
x=round(1+(199-w)*rand(1,100));
y=round(1+(199-h).*rand(1,100));
  
x_dash=x+w;
y_dash=y+h;
  
if all(im(x:x_dash,y:y_dash,2)~=1)
im(x:x_dash,y:y_dash,3)=0;
im(x:x_dash,y:y_dash,1:2)=1;
break;
end
end
end

imshow(im);


%
% Part 3
%

% 
% Create a copy of current image.
%
im2 = im;

%
% Extract the size of image.
%
[numRows numColumns numDepth] = size(im2);

%
% Set every 40th row as white.
%
im2(1 : 40 : numRows, :, :) = 1;

%
% Set every 40th column as white.
%
im2(:, 1 : 40 : numColumns, :) = 1;

%
% Hold on, and draw (superimpose) this second image.
%


hold on;
imshow(im2);

Following is the run :

>> 
>> image_yellow_white


Related Solutions

Using Matlab 1. Create a color image of size 200 × 200. The image should have...
Using Matlab 1. Create a color image of size 200 × 200. The image should have a blue background. 2. Create 100 yellow regions within the image that have a variable size. More specifically, their width should be an odd number and vary between 3 and 7 and their height should also be an odd number and vary between 3 and 7. For example, you may get rectangular regions of size 3 × 3, 3 × 5, 5 × 3,...
1-Pupils should be black in color, equal in size, normally 3-7 mm in diameter and have...
1-Pupils should be black in color, equal in size, normally 3-7 mm in diameter and have smooth border. -true -false 2-cilyball whist In order to assess the client respiratory system especially if he or she is suspected to have extra fluid around or inside lungs, we ask the client to repeat such words as "blue moon" or "one, two, three'. The terminology used to describe this technique is a. Respiratory auscultation. b. Tactile fremitus. C. Thoracentesis. d. Respiratory excursion. 3-The...
a) Copper solutions are typically blue to blue green in color. What color of light would...
a) Copper solutions are typically blue to blue green in color. What color of light would they be expected to absorb in the greatest amount? Red Violet Blue Green b) Based on your answer to the previous question (hopefully you have the correct answer), what wavelength range would you expect to see the maximum absorption of light (in the visible range)? 500 nm to 600 nm 400 nm to 500 nm 300 nm to 400 nm 600 nm to 700...
Create a class named Blanket with fields for a blanket’s size, color, material, and price. Include...
Create a class named Blanket with fields for a blanket’s size, color, material, and price. Include a constructor that sets default values for the fields as Twin, white, cotton, and $30.00. Include a set method for each of the first three fields. The method that sets size adds $10 to the base price for a double blanket, $25 for a queen blanket, and $40 for a king. The method that sets the material adds $20 to the price for wool...
Full color in domestic cats is dominant over dilute color. Of 600 cats observed, 200 have...
Full color in domestic cats is dominant over dilute color. Of 600 cats observed, 200 have dilute color. If this population is in Hardy-Weinberg equilibrium, what is the frequency of the dilute allele? How many of the 400 cats with full color are likely to be heterozygous?
Create a page with jQuery. 1. Add "IMG.jpg" with size WIDTH="200" HEIGHT="60", give an id. 2....
Create a page with jQuery. 1. Add "IMG.jpg" with size WIDTH="200" HEIGHT="60", give an id. 2. Use mouseenter(), width(), and height() to resize the picture to 800 by 230. 3. Use mouseleave, width(), and height() to resize the picture to 200 by 60.
#Create a class called FrapOrder. FrapOrder should #have two attributes (instance variables): size and #extra_shots. Make...
#Create a class called FrapOrder. FrapOrder should #have two attributes (instance variables): size and #extra_shots. Make sure the variable names match those #words. size will be a character, either "S", "M", or "L". #extra_shots will be an integer. # #FrapOrder should have a constructor with two required #parameters, one for each of those attributes (size and #extra_shots, in that order). # #FrapOrder should also have a method called get_total. #get_total should calculate the total cost of the order. #If size...
Write a program that is capable of detecting the color brown in an image taken by...
Write a program that is capable of detecting the color brown in an image taken by a webcam using OpenCV python code.
In mice the allele for blue coat color (B) pink coat color (b). The allele for...
In mice the allele for blue coat color (B) pink coat color (b). The allele for long tail (T) is dominant of the allele for short tail (t). 1) If alleles of the two genes Assort Independently, what types of gametes will BbTt mice produce? What is the expected frequency of each gamete among all gametes produced?
Most people like the color blue; it is the favorite color of many people. Do we...
Most people like the color blue; it is the favorite color of many people. Do we like blue because we associate it with activities we have enjoyed under a blue sky? Maybe we choose blue cars and blue shirts because we are classically conditioned to respond favorable to blue. What is the unconditioned stimulus? What is the unconditioned response? What is the conditioned stimulus? What is the conditioned response? ​Why do we like blue cars and blue shirts? Many people...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT