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
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
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
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
2016 年 3 月 6 日
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
2016 年 3 月 6 日
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
2016 年 3 月 7 日
Walter Roberson
2016 年 3 月 7 日
Post the code you have created so far, and indicate a specific problem you have with it.
abory kikla
2016 年 3 月 7 日
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
2016 年 3 月 7 日
編集済み: abory kikla
2016 年 3 月 7 日
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
2016 年 3 月 7 日
編集済み: abory kikla
2016 年 3 月 7 日
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
2016 年 3 月 9 日
編集済み: abory kikla
2016 年 3 月 9 日
abory kikla
2016 年 3 月 12 日
編集済み: abory kikla
2016 年 3 月 12 日
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
2016 年 3 月 12 日
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
2016 年 3 月 12 日
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
2016 年 3 月 13 日
編集済み: abory kikla
2016 年 3 月 13 日
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
2016 年 3 月 13 日
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
2016 年 3 月 14 日
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
2016 年 3 月 14 日
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
2020 年 12 月 29 日
i want to draw this using checkerboard can u help
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.
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)
カテゴリ
ヘルプ センター および File Exchange で Red についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



