MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi test

Learn moreOpportunities for recent engineering grads.

Apply TodayThe AVIRIS data sometimes is provided uncropped. This creates edge regions with values of "-50". Shown is AVIRIS Moffett Field image Layer 1 (400nm) and a zoom of the top-right corner. The dark blue on the edges is non-imaged ground.

To expedite processing a mask can be employed. For compression a bit mask is applicable. The challenge is to create a bit mask for this image and some other test cases.

**Input:** m ( 2-D uint16 array with zero and non-zero values )

**Output:** bmv (uint8 bit map vector with 0s at a==0 and 1s for a>0 locations)

Note: Input arrays may not be modulo 8. Append 0s as needed.

**Example:**

- m=[ 10 0 20; 15 12 0; 0 8 2] becomes mb=[1 0 1;1 1 0;0 1 1].
- The idx series is mb(:)=[1 1 0 0 1 1 1 0 1]' .
- This is 9 long so need to append 7 zeros.
- Converting the binary to uint8 values yields bmv=[206 128].

This bit mask saves 5% of total image size, yet is itself highly wasteful for compression since only the edges are impacted. A follow-up challenge will be to find the maximum-area non-zero inscribed rectangle.

29 correct solutions
22 incorrect solutions

Last solution submitted on Jan 13, 2015

2 Comments

Richard Zapor
on 11 Aug 2012

Fascinating array re-sizing followed by an impressive and powerful usage of a reshape parameter, which is rarely used.
Thank you

Khaled Hamed
on 12 Aug 2012

Thank you. Actually, I learned most of these tricks and many more here at Cody.

1 Comment