getting pixels information of the image
17 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hii guys..
I want to get the pixels information of a black and white image in 8 bit binary format.
what is the best way to do that?
1 comentario
Geoff Hayes
el 5 de Abr. de 2020
Divya - please clarify with an example of what you are looking for. Do you have a mxn image of unsigned integers? Are the integers already 8-bit? Do you want to write out (to text file) or put in a cell array the 8-bit binary strings for each pixel?
Respuestas (2)
Harshendra Shah
el 9 de Abr. de 2020
Hi Divya,
You can use impixel function to determine the values of one or more pixels in an image and return the values in a variable.
After getting the pixel values you can convert those values into 8-bit binary vector by using de2bi function.
You can refer to the following MATLAB Answers for better understanding:
I hope this helps.
0 comentarios
Image Analyst
el 9 de Abr. de 2020
Try this. Adapt as needed.
% Create some sample data - a small image.
grayImage = uint8(10*magic(5))
[rows, columns] = size(grayImage)
% Loop over all locations giving the gray level in decimal and binary.
for col = 1 : columns
for row = 1 : rows
thisGrayLevel = grayImage(row, col);
binaryString = dec2bin(thisGrayLevel);
fprintf('grayImage(%d, %d) = %d = "%s".\n', ...
row, col, thisGrayLevel, binaryString);
end
end
You'll see
grayImage =
5×5 uint8 matrix
170 240 10 80 150
230 50 70 140 160
40 60 130 200 220
100 120 190 210 30
110 180 250 20 90
rows =
5
columns =
5
grayImage(1, 1) = 170 = "10101010".
grayImage(2, 1) = 230 = "11100110".
grayImage(3, 1) = 40 = "101000".
grayImage(4, 1) = 100 = "1100100".
grayImage(5, 1) = 110 = "1101110".
grayImage(1, 2) = 240 = "11110000".
grayImage(2, 2) = 50 = "110010".
grayImage(3, 2) = 60 = "111100".
grayImage(4, 2) = 120 = "1111000".
grayImage(5, 2) = 180 = "10110100".
grayImage(1, 3) = 10 = "1010".
grayImage(2, 3) = 70 = "1000110".
grayImage(3, 3) = 130 = "10000010".
grayImage(4, 3) = 190 = "10111110".
grayImage(5, 3) = 250 = "11111010".
grayImage(1, 4) = 80 = "1010000".
grayImage(2, 4) = 140 = "10001100".
grayImage(3, 4) = 200 = "11001000".
grayImage(4, 4) = 210 = "11010010".
grayImage(5, 4) = 20 = "10100".
grayImage(1, 5) = 150 = "10010110".
grayImage(2, 5) = 160 = "10100000".
grayImage(3, 5) = 220 = "11011100".
grayImage(4, 5) = 30 = "11110".
grayImage(5, 5) = 90 = "1011010".
0 comentarios
Ver también
Categorías
Más información sobre Convert Image Type en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!