Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

MATLAB Can you help me fix the code, can't swap colors in a different dirrection -----------------------------------------my code-------------------------------------------- clear; clc; clear all; x = ones(256,256); %preallocate

MATLAB

Can you help me fix the code, can't swap colors in a different dirrection

-----------------------------------------my code--------------------------------------------

clear; clc; clear all;

x = ones(256,256); %preallocate x for efficiency

%establish RGB range red = 0:255; green = 0:255; blue = 0:255;

for i = 1:256 red = 255-(i-1); for j = 1:256 %green = -(j-1)+(i-1); %green = 255-((-(j-1))^2+(255-(i-1))^2)^0.5; %green = 255-max(j-1,255-(i-1)); %green = ((i.^2)/(256))+((j.^2)/(256)); green = (i*(256-j))/256; blue = (j-1); %each cell in the 256x256 is asigned a different value for Red, %Green and Blue depending on its positon and layer x(i,j,3)=red; x(i,j,2)=green; x(i,j,1)=blue; %CORRECT end end

figure colormap gray %converts single-layer matrices to grayscale subplot(221); %plots the red channel in the top-left imagesc(uint8(x(:,:,1))); title('Red Layer');

subplot(222); %plots the green channel in the top-right imagesc(uint8(x(:,:,2))); title('Green Layer');

subplot(223); %plots the blue channel in the bottom-left imagesc(uint8(x(:,:,3))); title('Blue Layer');

subplot(224); %plots the layered color-gradient in the bottom-right imagesc(uint8(x)); title('Problem 2');

------------------------Problem statement--------------------------------------------------

Using the technique described above, create your own image, of size 256 x 256 pixels, which contains gradations of color. This time, the corners are (clockwise from the top left) purple, blue, green and red. The intermediate points are once again smoothly shaded from one end to the other. There is smoothness both horizontally and vertically, but NOT diagonally (see the individual layer images). You can see the image you should create below, as well as the figure with 4 subplots. Take a close look at the Green Layer!

image text in transcribed

create your own image, of size 256 x 256 pixels, which contains gradations of color. This time, the corners are (clockwise from the top left) purple, blue, green and red. The intermediate points are once again smoothly shaded from one end to the other There is smoothness both horizontally and vertically, but NOT diagonally (see the individual layer images). You can see the image you should create below, as well as the figure with 4 subplots. Take a close look at the Green Layer! Dlue Layer

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Secrets Of Analytical Leaders Insights From Information Insiders

Authors: Wayne Eckerson

1st Edition

1935504347, 9781935504344

Students also viewed these Databases questions

Question

4-25. You neglected to sign the enclosed contract.

Answered: 1 week ago

Question

4-27. You failed to enclose your instructions for your new will.

Answered: 1 week ago