16-bit

Numpy and 16-bit PGM

ⅰ亾dé卋堺 提交于 2019-11-27 13:40:11
What is an efficient and clear way to read 16-bit PGM images in Python with numpy? I cannot use PIL to load 16-bit PGM images due to a PIL bug . I can read in the header with the following code: dt = np.dtype([('type', 'a2'), ('space_0', 'a1', ), ('x', 'a3', ), ('space_1', 'a1', ), ('y', 'a3', ), ('space_2', 'a1', ), ('maxval', 'a5')]) header = np.fromfile( 'img.pgm', dtype=dt ) print header This prints the correct data: ('P5', ' ', '640', ' ', '480', ' ', '65535') But I have a feeling that is not quite the best way. And beyond that, I'm having trouble how to figure out how to read in the

Print integer to console in x86 assembly

允我心安 提交于 2019-11-27 05:10:59
When I add two values in 16 bit assembly, what is the best way to print the result to console? At the moment I have this code: ;;---CODE START---;; mov ax, 1 ;put 1 into ax add ax, 2 ; add 2 to ax current value mov ah,2 ; 2 is the function number of output char in the DOS Services. mov dl, ax ; DL takes the value. int 21h ; calls DOS Services mov ah,4Ch ; 4Ch is the function number for exit program in DOS Services. int 21h ; function 4Ch doesn't care about anything in the registers. ;;---CODE END---;; I think that dl value should be in ASCII code, but I'm not sure how to convert ax value after

How to disassemble 16-bit x86 boot sector code in GDB with “x/i $pc”? It gets treated as 32-bit

泪湿孤枕 提交于 2019-11-26 20:58:50
For example, with a boot sector that BIOS prints a to the screen main.asm : org 0x7c00 bits 16 cli mov ax, 0x0E61 int 0x10 hlt times 510 - ($-$$) db 0 dw 0xaa55 Then: nasm -o main.img main.asm qemu-system-i386 -hda main.img -S -s & gdb -ex 'target remote localhost:1234' \ -ex 'break *0x7c00' \ -ex 'continue' \ -ex 'x/3i $pc' I get: 0x7c00: cli 0x7c01: mov $0x10cd0e61,%eax 0x7c06: hlt So it looks like the mov ax, 0x0E61 was interpreted as a 32-bit mov %eax and ate up the next instruction int 0x10 as data. How can I tell GDB that this is 16-bit code? See also: in 2007 a GDB dev replied "use

Python and 16 Bit Tiff

让人想犯罪 __ 提交于 2019-11-26 20:02:01
问题 How can I convert and save a 16 bit single-channel TIF in Python? I can load a 16 and 32 bit image without an issue, and see that the 32 bit image is mode F and the 16 bit image is mode I;16S : import Image i32 = Image.open('32.tif') i16 = Image.open('16.tif') i32 # <TiffImagePlugin.TiffImageFile image mode=F size=2000x1600 at 0x1098E5518> i16 # <TiffImagePlugin.TiffImageFile image mode=I;16S size=2000x1600 at 0x1098B6DD0> But I am having trouble working with the 16 bit image. If I want to

Numpy and 16-bit PGM

不打扰是莪最后的温柔 提交于 2019-11-26 16:26:47
问题 What is an efficient and clear way to read 16-bit PGM images in Python with numpy? I cannot use PIL to load 16-bit PGM images due to a PIL bug. I can read in the header with the following code: dt = np.dtype([('type', 'a2'), ('space_0', 'a1', ), ('x', 'a3', ), ('space_1', 'a1', ), ('y', 'a3', ), ('space_2', 'a1', ), ('maxval', 'a5')]) header = np.fromfile( 'img.pgm', dtype=dt ) print header This prints the correct data: ('P5', ' ', '640', ' ', '480', ' ', '65535') But I have a feeling that is

How to determine a Python variable&#39;s type?

安稳与你 提交于 2019-11-26 00:26:26
问题 How do I see the type of a variable whether it is unsigned 32 bit, signed 16 bit, etc.? How do I view it? 回答1: Python doesn't have the same types as C/C++, which appears to be your question. Try this: >>> i = 123 >>> type(i) <type 'int'> >>> type(i) is int True >>> i = 123456789L >>> type(i) <type 'long'> >>> type(i) is long True >>> i = 123.456 >>> type(i) <type 'float'> >>> type(i) is float True The distinction between int and long goes away in Python 3.0, though. 回答2: You may be looking