how to convert an 8x8 matrix to a texture image?
11 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I have an 8x8 matrix.Each element in the matrix should represent the intensity values and then convert it into a gray scale image having 8x8 blocks and each block should fill with the intensity value. I mean I should get the image given below
here, the first block has an intensity value i,the second block j and so on. then I need to find out the gray levels and the no. of pixels corresponding to the gray levels. Please help me to do this.
4 Commenti
Image Analyst
il 14 Ago 2015
You say "I have an 8x8 matrix" - where did this matrix come from? Is this the "image", or something else? If it's the image, you're done because a "matrix" is already an image. If it's something else, then you need to explain what you want to do. For example, do you merely want to replicate that 8x8 image into a larger image - this is what I did in my answer.
You say you want to take that 8x8 matrix (whatever it is) and "convert it into a gray scale image having 8x8 blocks and each block should fill with the intensity value." So, what is the size of the final image? How many 8-by-8 blocks of pixels are going across and down the final, larger image? Obviously the final image number of pixels should be a multiple of 8, but is it 1024 pixels across? 512? 960? What???
Until you clarify these questions, we're just all guessing. Please clarify to save time and get you exactly the answer you need.
Risposte (4)
Image Analyst
il 11 Ago 2015
The 8x8 array is already an image. Simply use repmat if you want to make it bigger
% Make one small 8 x 8 matrix.
one8x8 = rand(8);
% Replicate it 60 times vertically and 80 times horizontally.
bigMatrix = repmat(one8x8, [60, 80]);
% Display it.
imshow(bigMatrix, []);
If you want one8x8 to be a uint8 instead of floating point, then multiply by 255 and cast it:
one8x8 = uint8(255 * rand(8));
1 Commento
Image Analyst
il 18 Set 2015
This is already an image. You can view it after multiplication by 255 by using [] in imshow():
newMatrix = 255 * double(oldMatrix);
imshow(newMatrix, []);
Make sure that if oldMatrix was uint8, you cast it to double before multiplying by 255 or else it will clip the values at 255 and the image will be mostly just white, 255.
Varun Pai
il 12 Ago 2015
Modificato: Varun Pai
il 12 Ago 2015
Please check below code. It may satisfy your requirement
image_8x8 = uint8(255.*rand(8)); figure, imshow(image_8x8),title('8 x 8 image generated random');
image_64x64 = uint8(zeros(64,64));
for i=0:7 for j=0:7 image_64x64(8*i+1:8*i+8,8*j+1:8*j+8) = image_8x8(i+1,j+1); end end
figure, imshow(image_64x64),title('64 x 64 image generated ');
[values,gray_levels] = imhist(image_64x64); %histogram figure, stem(gray_levels,values),title('histogram') xlabel('gray levels'); ylabel('number of pixels');
Please accept if it is OK.
1 Commento
Walter Roberson
il 18 Set 2015
YourIntensityImage = uint8(rand(8,8)*255); %fake data for illustration
expanded_image = uint8(kron(double(YourIntensityImage), ones(8,8))); %kron does not accept uint8 directly
0 Commenti
Saikat Banerjee
il 30 Gen 2021
I think that this person is talking about digital matrix. A digital matrix is useful for NDT (non-destructive testing). The definition of digital matrix is :-
A standard 8 x 8 matrix contains 64 gray levels. Moving from left to right along a row of the matrix, each box is 1/64 brighter than the box preceding it. The boxes along each row are 1/8 brighter than the boxes in the row above. Each box contains pixels of identical value, but because of an optical phenomenon called the match bend effect, each box appears to be lighter on the top and darker on the bottom.
Now this being the matrix try to solve it. You shall get it in any NDT handbook
1 Commento
Image Analyst
il 30 Gen 2021
That sounds like the definition of a very specific type of output from a very specific type of instrument. It is not a definition of a digital matrx in general. For example, this is a digital matrix which does not fit that description yet is a totally valid digital matrix.
m = randi(9, 7, 5);
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!