how to code the following program in MATLAB 2010
Show older comments
open 24-bit color image in read mode
store image height to m and width to n, respectively
declare two 2-D Matrices, matrix[m][n], matrix1[m][n]
read pixel one by one until end of file
{
matrix1[i][j] = bi.getRGB(i,j)
b1[i][j]= (bi.getRGB(i,j)) & 0x000000FF
g1[i][j]= (bi.getRGB(i,j) & 0x0000FF00) >> 8
r1[i][j]= (bi.getRGB(i,j) & 0x00FF0000) >> 16
int avg = (r1[i][j]+g1[i][j]+b1[i][j])/3
int newRGB = 0xFF000000 + (avg << 16) + (avg << 8 ) + avg
matrix[i][j] = newRGB
}
write matrix[m][n] to another image file
close all the files
Accepted Answer
More Answers (0)
Categories
Find more on Convert Image Type in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!