Extracts the specified number of least significant bits and normalizes them. - Keeps only the lowest `bits` LSBs of each channel. - Normalizes the result to fill the 8-bit range for visibility.
(image, bits)
| 801 | |
| 802 | |
| 803 | def extract_lsb_and_normalize(image, bits): |
| 804 | """ |
| 805 | Extracts the specified number of least significant bits and normalizes them. |
| 806 | - Keeps only the lowest `bits` LSBs of each channel. |
| 807 | - Normalizes the result to fill the 8-bit range for visibility. |
| 808 | """ |
| 809 | lsb_image = image & ((1 << bits) - 1) # Keep only the `bits` least significant bits |
| 810 | return (lsb_image * (255 // ((1 << bits) - 1))).astype(np.uint8) # Normalize |
| 811 | |
| 812 | |
| 813 | def is_elf_using_yara(filepath): |