We are about to switch to a new forum software. Until then we have removed the registration on this forum.
PImage img;
int[][] msb;
int[][] lsb;
void setup() {
size(300, 500); // same width, twice the height
img = loadImage("women.gif");
println(img.width, img.height);
msb = new int[img.width][img.height];
lsb = new int[img.width][img.height];
noLoop();
}
void draw() {
image(img, 0, 0);
loadPixels();
int x=0,y=0;
img.loadPixels();
for (int i = 0 ; i < img.width ; i++) {
for(int j=0;j<img.height;j++){
int loc = i+j*img.width;
int Pixels = img.pixels[loc] & 0xff;
msb[i][j] = (Pixels >> 23) &0x1 ;
lsb[i][j] = Pixels & 0x1;
pixels[loc+(img.width * img.height)] = 0xff000000|msb[i][j] << 16 | msb[i][j] << 8|msb[i][j] & 0xff;
}
}
// debug
for (int i = 0 ; i < img.width ; i++) {
for(int j=0;j<img.height;j++){
print(msb[i][j]);
}
println("\n");
}
updatePixels();
}
Answers
Pls check this code ?
Does it work? If not, in which way does it not work?
No it is showing the blank image what i am doing is i am getting all the most significant bit and least significant bit and making the matrix of it then i am updating the the pixels with most significant bit And acc. to bit phase slicing if i display the most significant bit it will show the actual image but the image would compress a little bit actually it is showing black image .
the mask here is limiting Pixels to the lower 8 bits. your msb will always be 0
you will end up, at best, with some blue.
warning: line 36 might crash processing. it doesn't like lots of output. and that's lots of output
How to resolve this problem
this change to line 24 should fix that. it's using only the blue channel, assuming it's greyscale again.
btw, uppercase letters, like Pixels, usually denote class names. calling a member variable Pixels is confusing.
Nop its same
but right shift by 7 won't give us most significant bit .
but only 8 bits are significant because r, g and b are all the same for greyscale.
post the image you're using so we're all using the same data
that's fine with my last change.
only what you're doing is setting pixels to either 0 or 1, absolutely black or ever so slightly less than absolutely black, so you can't see a thing
try this
which sets things to 0 or 0x404040 depending on the msb of the input
it should show us image but their is nothing but shades and in bit phase slicing msb always display the actual image
do you have a link to somewhere that describes 'bit phase slicing'?
http://www.ft.unicamp.br/docentes/magic/khoros/html-dip/c4/s12/front-page.html koogs can u suggest me any book on computer vision related to this plateform only
ok, think i've got it now...
that woman image is a bit odd, first 3 planes are all the same colour, like the histogram for that image is stretched out somehow (it is, you can see it in a decent graphics program)
[edit, black and white were inverted, tested with beach photo - http://www.ft.unicamp.br/docentes/magic/khoros/html-dip/c4/s12/ipanema-leblon.gif ]
also, Bit Plane Slicing