i am new at matlab and i want Create color checkerboard

Please help me solve this Lab-
Coursework1 :
1 Create checkerboard image using MATLAB
1 Use the matrix manipulation to implement a color chessboard image size 1024* 1024, where each stone size 32 * 32 without any loop statement.
2 Create checkerboard image using MATLAB
1 Use the matrix manipulation to implement a color chessboard image size 1024* 1024 ,where each stone size 32 * 32 based on loop statement.  Use checkerboard/kron function to implement a color chessboard image size 1024* 1024 ,where each stone size 32 * 32.?
[Merged from duplicate question]
I want to create a chess colored using the random function and displayed using the command Amco >> Can you do it

2 件のコメント

Walter Roberson
Walter Roberson 2016 年 3 月 6 日
編集済み: Walter Roberson 2016 年 3 月 6 日
Yes of course I can do it. But it is your homework, and you need to work on it.
(Hint: I posted code that could easily be adapted for this, no more than 6 months ago.)
Jan
Jan 2016 年 3 月 6 日
The link does work now. Please, abory kikla, show us what you have tried so far and ask a specific question. The forum will not solve your homework, because this would not be constructive.

サインインしてコメントする。

回答 (1 件)

Image Analyst
Image Analyst 2016 年 3 月 6 日

2 投票

Try using the checkerboard function. Then threshold and call bwlabel() to assign every square a unique ID number. Then make up a colormap long enough so that you get a color for every square (this is where you could use rand()). Then apply the colormap with ind2rgb(), and finally show the RGB image with imshow(). That should be enough hints. Now, lets see your code that carries out those steps. You should get a checkerboard where the "black" squares are black and the "white" squares each have a unique color.

31 件のコメント

abory kikla
abory kikla 2016 年 3 月 6 日
Can you write code me please
Image Analyst
Image Analyst 2016 年 3 月 6 日
You mean you want me to do your homework for you? Sorry, I don't think that would be ethical for me to do 100% of your homework/lab for you, nor for you to just ask someone for code and to turn in someone else's code as your own. I've given you hints, more than the instructions did, and that should be enough.
abory kikla
abory kikla 2016 年 3 月 6 日
Well,, what means threshold in MATLAB
Image Analyst
Image Analyst 2016 年 3 月 6 日
Like this:
binaryImage = grayImage > 0;
Do you want to show us the code where you used checkerboard to create the gray scale image?
abory kikla
abory kikla 2016 年 3 月 7 日
I tried and did not give the desired result,, and intercourse with the instructions in the full code,, and the result was a pixel not color chess board,,
Walter Roberson
Walter Roberson 2016 年 3 月 7 日
Post the code you have created so far, and indicate a specific problem you have with it.
abory kikla
abory kikla 2016 年 3 月 7 日
Excuse How do I use the rand function for So that I can get the color of each square
Image Analyst
Image Analyst 2016 年 3 月 7 日
Again, post the code. To get a colormap with numColors random colors, you'd do
cmap = rand(numColors, 3);
abory kikla
abory kikla 2016 年 3 月 7 日
編集済み: abory kikla 2016 年 3 月 7 日
There is an error when performing random function:
Binay Image = checkerboard;
Binay Image = BinayImage> 0;
BinayImage = bwlabel (BinayImage);
BinayImage = rand (BinayImage, 3);
This is a mistake((Warning: Input arguments must be scalar.)) ......
Do you use his place(( BinayImage =rand(size(BinayImage));
Image Analyst
Image Analyst 2016 年 3 月 7 日
Call it binaryImage exactly like I did. You cannot have spaces in variable names like you did where you have Binay and Image (two words with a space between them). You also need to pass arguments to checkerboard().
abory kikla
abory kikla 2016 年 3 月 7 日
編集済み: abory kikla 2016 年 3 月 7 日
No space between the names of variables and How do I pass the arguments
Image Analyst
Image Analyst 2016 年 3 月 7 日
abory, did you look up the help for checkerboard? It says
I = checkerboard(n,p,q)
That's how you pass arguments to it. You just need to get the right numbers for n, p, and q based on what your homework is asking.
If you don't know how to pass arguments to functions you'll get up to speed quickly by following the "Getting started" section of help. You won't get very far in MATLAB, or any programming language until you learn how to pass arguments. Also check out this link
abory kikla
abory kikla 2016 年 3 月 9 日
編集済み: abory kikla 2016 年 3 月 9 日
How do you use the rand() and ind2rgb()function in the following code so that gives me a color checkerboard? I used them, but the result is not required. :
I=checkerboard(40,32,32);
>> I=I>0;
>> bwlabel(I);
>> imshow(I);
abory kikla
abory kikla 2016 年 3 月 12 日
編集済み: abory kikla 2016 年 3 月 12 日
This code has been completed properly based on your instructions:
J=checkerboard(64,4,4);
J=J>0;
>> bw=bwlabel(J,4);
S=rand(30,3,4);
V=ind2rgb(bw,S);
imshow(V);
Image Analyst
Image Analyst 2016 年 3 月 12 日
abory. Glad I could help. Usually in that case, the poster "Accepts this answer.". Thanks in advance for doing that. You're welcome.
abory kikla
abory kikla 2016 年 3 月 12 日
Can I use conversions rather than using ind2rgb() function to get the same result and how
Image Analyst
Image Analyst 2016 年 3 月 12 日
If you want to create an RGB image by directly writing values into certain locations, you can do that, but it would be a lot more involved.
abory kikla
abory kikla 2016 年 3 月 12 日
How can I?
Image Analyst
Image Analyst 2016 年 3 月 12 日
For example, to make a yellow rectangle:
rgbImage = zeros(640, 480, 3, 'uint8');
% Extract the individual red, green, and blue color channels.
redChannel = rgbImage(:, :, 1);
greenChannel = rgbImage(:, :, 2);
blueChannel = rgbImage(:, :, 3);
% Make a square some RGB color.
redChannel(100:150, 200:350) = 255;
greenChannel(100:150, 200:350) = 213;
blueChannel(100:150, 200:350) = 57;
% Recombine separate color channels into a single, true color RGB image.
rgbImage = cat(3, redChannel, greenChannel, blueChannel);
% Display it.
imshow(rgbImage);
abory kikla
abory kikla 2016 年 3 月 13 日
編集済み: abory kikla 2016 年 3 月 13 日
Well,,,, this is what I want, but how linking three Previous matrices " rgbImage",,with the rand() function to give me the following figure or like him.
Image Analyst
Image Analyst 2016 年 3 月 13 日
You have to know the starting row and column, and ending row and column of every square. You preferred to do it the hard way, so that is what you need to do to do it the hard way.
abory kikla
abory kikla 2016 年 3 月 13 日
How can I make the rgbImage matrix take the rand function ...please
Image Analyst
Image Analyst 2016 年 3 月 13 日
I don't know what that means. I showed you how to assign values. Those values can be a constant, or can be random or whatever. Maybe you want to use imnoise().
abory kikla
abory kikla 2016 年 3 月 14 日
Mr. analyst,,,Required of me create a 3 matrices Then merged into with some by cat function..Then make a the merged matrix Taking the values of rand function..Previous your example be part of the answer But it does draw one square in the image ,Here it is required of me to be All matrix cells Colored random colors,,,,i hope you understand what i mean and i hope you can help me.
Image Analyst
Image Analyst 2016 年 3 月 14 日
I've given you the code to make a rectangle. All you have to do to complete your homework is to get random colors instead of the one I used, and to do that in different square locations. If I do that for you then I will have done 100% of your homework and you would be in danger of plagiarizing and that would be unethical. Really, it's not that hard and you, being a smart engineer, should easily be able to accomplish it, even if you are a MATLAB beginner. There's not much left to do. Good luck.
abory kikla
abory kikla 2016 年 3 月 14 日
Mr. analyst,,I tried using loops and executed But I am having a problem with a MATLAB program after the implementation of the code gets his deadlock,, and was forced to restart the computer every time the code is executed
Image Analyst
Image Analyst 2016 年 3 月 14 日
Try hitting control-c, or step through it with the debugger to see where you are getting into an infinite loop, or use fprintf() to print useful information to the command line as your script progresses along.
Hassaan Khan
Hassaan Khan 2020 年 12 月 29 日
i want to draw this using checkerboard can u help
Image Analyst
Image Analyst 2020 年 12 月 29 日
Make it easy to help you, not hard. Supply us with a list of the RGB values of the various colors that you want. I don't want to type those in - I'd rather have you do that. After that, just use indexing to set the colors for each square - nothing magic or tricky about it.
DGM
DGM 2022 年 11 月 22 日
編集済み: DGM 2022 年 11 月 22 日
Here is one way:
% parameters
CT = [0 0 0; 253 242 0; 238 15 140; 0 174 237; 255 255 255]/255; % the tile colors
squaresize = [20 20]; % the size of squares [y x]
nsquares = [11 11]; % the tiling [y x]
sizeout = round(squaresize.*nsquares);
outpict = toeplitz([1 2 3 1 4 1 5 1 2 3 1],[1 5 1 4 1 3 2 1 5 1 4]); % create 1px/tile index image
outpict = imresize(outpict,sizeout,'nearest'); % expand to final size
outpict = ind2rgb(outpict,CT); % apply colormap
imshow(outpict)
Considering that the pattern appears to be cyclic, I imagine it can be generalized a bit more.
% parameters
CT = [0 0 0; 253 242 0; 238 15 140; 0 174 237; 255 255 255]/255; % the tile colors
pat = [1 2 3 1 4 1 5]; % the base tile sequence
squaresize = [20 20]; % the size of squares [y x]
nsquares = [21 21]; % the tiling [y x]
sizeout = round(squaresize.*nsquares);
c = repmat(pat,[1 ceil(nsquares(1)/numel(pat))]);
r = circshift(fliplr(repmat(pat,[1 ceil(nsquares(2)/numel(pat))])),1);
outpict = toeplitz(c(1:nsquares(1)),r(1:nsquares(1))); % create 1px/tile index image
outpict = imresize(outpict,sizeout,'nearest'); % expand to final size
outpict = ind2rgb(outpict,CT); % apply augmented colormap
imshow(outpict)
See this thread for more "colored checkerboard" answers.

サインインしてコメントする。

カテゴリ

質問済み:

2016 年 3 月 6 日

編集済み:

DGM
2022 年 11 月 22 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by