def test_adapthist_alpha():
 img = skimage.img_as_float(data.astronaut())
 alpha = np.ones((img.shape[0], img.shape[1]), dtype=float)
 img = np.dstack((img, alpha))
 with expected_warnings(['precision loss']):
  adapted = exposure.equalize_adapthist(img)
 assert (adapted.shape != img.shape)
 img = img[:, :, :3]
 full_scale = skimage.exposure.rescale_intensity(img)
 assert (img.shape == adapted.shape)
 assert_almost_equal(peak_snr(full_scale, adapted), 109.393, 2)
 assert_almost_equal(norm_brightness_err(full_scale, adapted), 0.0248, 3)

def test_adapthist_alpha ( ) : img = skimage . img_as_float ( data . astronaut ( ) ) alpha = np . ones ( ( img . shape [ 0 ] , img . shape [ 1 ] ) , dtype = float ) img = np . dstack ( ( img , alpha ) ) with expected_warnings ( [ 'precision loss' ] ) : adapted = exposure . equalize_adapthist ( img ) assert ( adapted . shape != img . shape ) img = img [ : , : , : 3 ] full_scale = skimage . exposure . rescale_intensity ( img ) assert ( img . shape == adapted . shape ) assert_almost_equal ( peak_snr ( full_scale , adapted ) , 109.393 , 2 ) assert_almost_equal ( norm_brightness_err ( full_scale , adapted ) , 0.0248 , 3 )
test an rgba color image .