image.process\feature\lbp_16f.mbt
93.2% · 221 / 237 points · 590 linesBackground color reports the state of each line. Underlined characters mark exact instrumented byte offsets; hover them to inspect the visit count.
- 1
///| - 2
/// # 局部二值模式 16-bit/float 变体 Local Binary Pattern 16-bit/float variants - 3
/// - 4
/// 16位/浮点 LBP lbp_16 / lbp_f - 5
/// 16位/浮点 LBP 16-bit/float LBP - 6
// 局部二值模式(LBP)16-bit/float 变体 - 7
// 支持 Image16 / ImageF 两种类型 - 8
- 9
// ========== 辅助函数 ========== - 10
- 11
///| - 12
fn read_u16_le_l(data : Bytes, offset : Int32) -> Int32 { - 13●
data[offset].to_int() + data[offset + 1].to_int() * 256 - 14
} - 15
- 16
///| - 17
fn write_u16_le_l(buf : Array[Byte], offset : Int32, val : Int32) -> Unit { - 18●
buf[offset] = (val & 0xFF).to_byte() - 19●
buf[offset + 1] = ((val >> 8) & 0xFF).to_byte() - 20
} - 21
- 22
///| - 23
fn read_float_le_l(data : Bytes, offset : Int32) -> Float { - 24●
let b0 = data[offset].to_int() - 25●
let b1 = data[offset + 1].to_int() - 26●
let b2 = data[offset + 2].to_int() - 27●
let b3 = data[offset + 3].to_int() - 28
let bits = b0 | (b1 << 8) | (b2 << 16) | (b3 << 24) - 29●
Float::reinterpret_from_int(bits) - 30
} - 31
- 32
///| - 33
fn write_f32_le_l(buf : Array[Byte], offset : Int32, val : Float) -> Unit { - 34●
let bits = val.reinterpret_as_int() - 35●
buf[offset] = (bits & 0xFF).to_byte() - 36●
buf[offset + 1] = ((bits >> 8) & 0xFF).to_byte() - 37●
buf[offset + 2] = ((bits >> 16) & 0xFF).to_byte() - 38●
buf[offset + 3] = ((bits >> 24) & 0xFF).to_byte() - 39
} - 40
- 41
///| - 42
fn get_pixel_safe_16( - 43
src : Array[Int32], - 44
x : Int32, - 45
y : Int32, - 46
c : Int32, - 47
ch : Int32, - 48
w : Int32, - 49
h : Int32, - 50
) -> Int32 { - 51●
let sx = @types.clamp_int(x, 0, w - 1) - 52●
let sy = @types.clamp_int(y, 0, h - 1) - 53
src[(sy * w + sx) * ch + c] - 54
} - 55
- 56
///| - 57
fn get_pixel_safe_f( - 58
src : Array[Float], - 59
x : Int32, - 60
y : Int32, - 61
c : Int32, - 62
ch : Int32, - 63
w : Int32, - 64
h : Int32, - 65
) -> Float { - 66●
let sx = @types.clamp_int(x, 0, w - 1) - 67●
let sy = @types.clamp_int(y, 0, h - 1) - 68
src[(sy * w + sx) * ch + c] - 69
} - 70
- 71
// 计算均匀 LBP 映射(跳变次数 <= 2) - 72
- 73
///| - 74
fn uniform_lbp_map(lbp_val : Int32) -> Int32 { - 75
// 计算 0->1 和 1->0 跳变次数 - 76●
let mut transitions = 0 - 77
let mut prev = (lbp_val >> 7) & 1 - 78
for i in 0..<8 { - 79●
let curr = (lbp_val >> i) & 1 - 80
if curr != prev { - 81○
transitions += 1 - 82
} - 83
prev = curr - 84
} - 85
if transitions <= 2 { - 86
// 均匀模式:计算 1 的个数作为标签(0-8) - 87●
let mut count = 0 - 88
for i in 0..<8 { - 89●
if ((lbp_val >> i) & 1) == 1 { - 90●
count += 1 - 91
} - 92
} - 93
count - 94
} else { - 95
// 非均匀模式 - 96○
9 - 97
} - 98
} - 99
- 100
// ========== 基本 LBP ========== - 101
- 102
///| - 103
/// 16-bit 基本局部二值模式(LBP)。输出 0-255 的编码值,存储为 16-bit。 - 104
/// @see lbp 8-bit 版本,本函数为 Image16 变体 - 105
pub fn lbp_16(img : @types.Image16) -> @types.Image16 raise @types.LoadError { - 106
// 输入验证 - 107●
if img.width <= 0 || img.height <= 0 { - 108●
raise @types.LoadError::DecodeFailed("lbp_16: 图像尺寸必须大于0") - 109
} - 110
if img.channels != 1 && img.channels != 3 && img.channels != 4 { - 111●
raise @types.LoadError::DecodeFailed("lbp_16: 仅支持 channels=1/3/4") - 112
} - 113
let expected_size = img.width * img.height * img.channels * 2 - 114●
if img.data.length() != expected_size { - 115●
raise @types.LoadError::DecodeFailed( - 116
"lbp_16: 数据大小不匹配,期望 " + - 117●
expected_size.to_string() + - 118
",实际 " + - 119●
img.data.length().to_string(), - 120
) - 121
} - 122
let ch = img.channels - 123●
let color_ch = if ch >= 3 { 3 } else { 1 } - 124
let w = img.width - 125
let h = img.height - 126
let n = w * h - 127
let bpp = ch * 2 - 128●
let out : Array[Byte] = Array::make(n * bpp, b'\x00') - 129●
let src : Array[Int32] = Array::make(n * ch, 0) - 130
for i in 0..<(n * ch) { - 131●
src[i] = read_u16_le_l(img.data, i * 2) - 132
} - 133
for c in 0..<color_ch { - 134●
for y in 1..<(h - 1) { - 135●
for x in 1..<(w - 1) { - 136●
let center = src[(y * w + x) * ch + c] - 137
let mut lbp_val = 0 - 138
if src[((y - 1) * w + (x - 1)) * ch + c] >= center { - 139●
lbp_val = lbp_val | 1 - 140
} - 141
if src[((y - 1) * w + x) * ch + c] >= center { - 142●
lbp_val = lbp_val | 2 - 143
} - 144
if src[((y - 1) * w + (x + 1)) * ch + c] >= center { - 145●
lbp_val = lbp_val | 4 - 146
} - 147
if src[(y * w + (x + 1)) * ch + c] >= center { - 148●
lbp_val = lbp_val | 8 - 149
} - 150
if src[((y + 1) * w + (x + 1)) * ch + c] >= center { - 151●
lbp_val = lbp_val | 16 - 152
} - 153
if src[((y + 1) * w + x) * ch + c] >= center { - 154●
lbp_val = lbp_val | 32 - 155
} - 156
if src[((y + 1) * w + (x - 1)) * ch + c] >= center { - 157●
lbp_val = lbp_val | 64 - 158
} - 159
if src[(y * w + (x - 1)) * ch + c] >= center { - 160●
lbp_val = lbp_val | 128 - 161
} - 162●
write_u16_le_l(out, (y * w + x) * bpp + c * 2, lbp_val) - 163
} - 164
} - 165
for y in 0..<h { - 166●
let y_inner = y >= 1 && y < h - 1 - 167
for x in 0..<w { - 168●
if y_inner && x >= 1 && x < w - 1 { - 169●
continue - 170
} - 171
let center = src[(y * w + x) * ch + c] - 172
let mut lbp_val = 0 - 173●
if get_pixel_safe_16(src, x - 1, y - 1, c, ch, w, h) >= center { - 174●
lbp_val = lbp_val | 1 - 175
} - 176●
if get_pixel_safe_16(src, x, y - 1, c, ch, w, h) >= center { - 177●
lbp_val = lbp_val | 2 - 178
} - 179●
if get_pixel_safe_16(src, x + 1, y - 1, c, ch, w, h) >= center { - 180●
lbp_val = lbp_val | 4 - 181
} - 182●
if get_pixel_safe_16(src, x + 1, y, c, ch, w, h) >= center { - 183●
lbp_val = lbp_val | 8 - 184
} - 185●
if get_pixel_safe_16(src, x + 1, y + 1, c, ch, w, h) >= center { - 186●
lbp_val = lbp_val | 16 - 187
} - 188●
if get_pixel_safe_16(src, x, y + 1, c, ch, w, h) >= center { - 189●
lbp_val = lbp_val | 32 - 190
} - 191●
if get_pixel_safe_16(src, x - 1, y + 1, c, ch, w, h) >= center { - 192●
lbp_val = lbp_val | 64 - 193
} - 194●
if get_pixel_safe_16(src, x - 1, y, c, ch, w, h) >= center { - 195●
lbp_val = lbp_val | 128 - 196
} - 197●
write_u16_le_l(out, (y * w + x) * bpp + c * 2, lbp_val) - 198
} - 199
} - 200
} - 201
if ch == 4 { - 202●
for i in 0..<n { - 203●
let alpha_off = i * bpp + 6 - 204
out[alpha_off] = img.data[alpha_off] - 205
out[alpha_off + 1] = img.data[alpha_off + 1] - 206
} - 207
} - 208
@types.Image16::{ - 209
width: w, - 210
height: h, - 211
channels: ch, - 212●
data: Bytes::from_array(out), - 213
} - 214
} - 215
- 216
///| - 217
/// float 基本局部二值模式(LBP)。输出归一化到 0.0-1.0(LBP值/255)。 - 218
/// @see lbp 8-bit 版本,本函数为 ImageF 变体 - 219
pub fn lbp_f(img : @types.ImageF) -> @types.ImageF raise @types.LoadError { - 220
// 输入验证 - 221●
if img.width <= 0 || img.height <= 0 { - 222●
raise @types.LoadError::DecodeFailed("lbp_f: 图像尺寸必须大于0") - 223
} - 224
if img.channels != 1 && img.channels != 3 && img.channels != 4 { - 225○
raise @types.LoadError::DecodeFailed("lbp_f: 仅支持 channels=1/3/4") - 226
} - 227
let expected_size = img.width * img.height * img.channels * 4 - 228●
if img.data.length() != expected_size { - 229●
raise @types.LoadError::DecodeFailed( - 230
"lbp_f: 数据大小不匹配,期望 " + - 231●
expected_size.to_string() + - 232
",实际 " + - 233●
img.data.length().to_string(), - 234
) - 235
} - 236
let ch = img.channels - 237◐
let color_ch = if ch >= 3 { 3 } else { 1 } - 238
let w = img.width - 239
let h = img.height - 240
let n = w * h - 241
let bpp = ch * 4 - 242●
let out : Array[Byte] = Array::make(n * bpp, b'\x00') - 243●
let src : Array[Float] = Array::make(n * ch, 0.0F) - 244
for i in 0..<(n * ch) { - 245●
src[i] = read_float_le_l(img.data, i * 4) - 246
} - 247
for c in 0..<color_ch { - 248●
for y in 1..<(h - 1) { - 249●
for x in 1..<(w - 1) { - 250●
let center = src[(y * w + x) * ch + c] - 251
let mut lbp_val = 0 - 252
if src[((y - 1) * w + (x - 1)) * ch + c] >= center { - 253●
lbp_val = lbp_val | 1 - 254
} - 255
if src[((y - 1) * w + x) * ch + c] >= center { - 256●
lbp_val = lbp_val | 2 - 257
} - 258
if src[((y - 1) * w + (x + 1)) * ch + c] >= center { - 259●
lbp_val = lbp_val | 4 - 260
} - 261
if src[(y * w + (x + 1)) * ch + c] >= center { - 262●
lbp_val = lbp_val | 8 - 263
} - 264
if src[((y + 1) * w + (x + 1)) * ch + c] >= center { - 265●
lbp_val = lbp_val | 16 - 266
} - 267
if src[((y + 1) * w + x) * ch + c] >= center { - 268●
lbp_val = lbp_val | 32 - 269
} - 270
if src[((y + 1) * w + (x - 1)) * ch + c] >= center { - 271●
lbp_val = lbp_val | 64 - 272
} - 273
if src[(y * w + (x - 1)) * ch + c] >= center { - 274●
lbp_val = lbp_val | 128 - 275
} - 276●
write_f32_le_l( - 277
out, - 278
(y * w + x) * bpp + c * 4, - 279●
Float::from_int(lbp_val) / 255.0F, - 280
) - 281
} - 282
} - 283
for y in 0..<h { - 284●
let y_inner = y >= 1 && y < h - 1 - 285
for x in 0..<w { - 286●
if y_inner && x >= 1 && x < w - 1 { - 287●
continue - 288
} - 289
let center = src[(y * w + x) * ch + c] - 290
let mut lbp_val = 0 - 291●
if get_pixel_safe_f(src, x - 1, y - 1, c, ch, w, h) >= center { - 292●
lbp_val = lbp_val | 1 - 293
} - 294●
if get_pixel_safe_f(src, x, y - 1, c, ch, w, h) >= center { - 295●
lbp_val = lbp_val | 2 - 296
} - 297●
if get_pixel_safe_f(src, x + 1, y - 1, c, ch, w, h) >= center { - 298●
lbp_val = lbp_val | 4 - 299
} - 300●
if get_pixel_safe_f(src, x + 1, y, c, ch, w, h) >= center { - 301●
lbp_val = lbp_val | 8 - 302
} - 303●
if get_pixel_safe_f(src, x + 1, y + 1, c, ch, w, h) >= center { - 304●
lbp_val = lbp_val | 16 - 305
} - 306●
if get_pixel_safe_f(src, x, y + 1, c, ch, w, h) >= center { - 307●
lbp_val = lbp_val | 32 - 308
} - 309●
if get_pixel_safe_f(src, x - 1, y + 1, c, ch, w, h) >= center { - 310●
lbp_val = lbp_val | 64 - 311
} - 312●
if get_pixel_safe_f(src, x - 1, y, c, ch, w, h) >= center { - 313●
lbp_val = lbp_val | 128 - 314
} - 315●
write_f32_le_l( - 316
out, - 317
(y * w + x) * bpp + c * 4, - 318●
Float::from_int(lbp_val) / 255.0F, - 319
) - 320
} - 321
} - 322
} - 323
if ch == 4 { - 324○
for i in 0..<n { - 325○
let alpha_off = i * bpp + 12 - 326
for b in 0..<4 { - 327○
out[alpha_off + b] = img.data[alpha_off + b] - 328
} - 329
} - 330
} - 331
@types.ImageF::{ - 332
width: w, - 333
height: h, - 334
channels: ch, - 335●
data: Bytes::from_array(out), - 336
} - 337
} - 338
- 339
// ========== 均匀 LBP ========== - 340
- 341
///| - 342
/// 16-bit 均匀局部二值模式(Uniform LBP)。输出 0-9 的标签值,存储为 16-bit。 - 343
/// @see lbp_uniform 8-bit 版本,本函数为 Image16 变体 - 344
pub fn lbp_uniform_16( - 345
img : @types.Image16, - 346
) -> @types.Image16 raise @types.LoadError { - 347
// 输入验证 - 348●
if img.width <= 0 || img.height <= 0 { - 349●
raise @types.LoadError::DecodeFailed( - 350
"lbp_uniform_16: 图像尺寸必须大于0", - 351
) - 352
} - 353
if img.channels != 1 && img.channels != 3 && img.channels != 4 { - 354○
raise @types.LoadError::DecodeFailed( - 355
"lbp_uniform_16: 仅支持 channels=1/3/4", - 356
) - 357
} - 358
let expected_size = img.width * img.height * img.channels * 2 - 359●
if img.data.length() != expected_size { - 360●
raise @types.LoadError::DecodeFailed( - 361
"lbp_uniform_16: 数据大小不匹配,期望 " + - 362●
expected_size.to_string() + - 363
",实际 " + - 364●
img.data.length().to_string(), - 365
) - 366
} - 367
let ch = img.channels - 368◐
let color_ch = if ch >= 3 { 3 } else { 1 } - 369
let w = img.width - 370
let h = img.height - 371
let n = w * h - 372
let bpp = ch * 2 - 373●
let out : Array[Byte] = Array::make(n * bpp, b'\x00') - 374●
let src : Array[Int32] = Array::make(n * ch, 0) - 375
for i in 0..<(n * ch) { - 376●
src[i] = read_u16_le_l(img.data, i * 2) - 377
} - 378
for c in 0..<color_ch { - 379●
for y in 1..<(h - 1) { - 380●
for x in 1..<(w - 1) { - 381●
let center = src[(y * w + x) * ch + c] - 382
let mut lbp_val = 0 - 383
if src[((y - 1) * w + (x - 1)) * ch + c] >= center { - 384●
lbp_val = lbp_val | 1 - 385
} - 386
if src[((y - 1) * w + x) * ch + c] >= center { - 387●
lbp_val = lbp_val | 2 - 388
} - 389
if src[((y - 1) * w + (x + 1)) * ch + c] >= center { - 390●
lbp_val = lbp_val | 4 - 391
} - 392
if src[(y * w + (x + 1)) * ch + c] >= center { - 393●
lbp_val = lbp_val | 8 - 394
} - 395
if src[((y + 1) * w + (x + 1)) * ch + c] >= center { - 396●
lbp_val = lbp_val | 16 - 397
} - 398
if src[((y + 1) * w + x) * ch + c] >= center { - 399●
lbp_val = lbp_val | 32 - 400
} - 401
if src[((y + 1) * w + (x - 1)) * ch + c] >= center { - 402●
lbp_val = lbp_val | 64 - 403
} - 404
if src[(y * w + (x - 1)) * ch + c] >= center { - 405●
lbp_val = lbp_val | 128 - 406
} - 407●
write_u16_le_l(out, (y * w + x) * bpp + c * 2, uniform_lbp_map(lbp_val)) - 408
} - 409
} - 410
for y in 0..<h { - 411●
let y_inner = y >= 1 && y < h - 1 - 412
for x in 0..<w { - 413●
if y_inner && x >= 1 && x < w - 1 { - 414●
continue - 415
} - 416
let center = src[(y * w + x) * ch + c] - 417
let mut lbp_val = 0 - 418●
if get_pixel_safe_16(src, x - 1, y - 1, c, ch, w, h) >= center { - 419●
lbp_val = lbp_val | 1 - 420
} - 421●
if get_pixel_safe_16(src, x, y - 1, c, ch, w, h) >= center { - 422●
lbp_val = lbp_val | 2 - 423
} - 424●
if get_pixel_safe_16(src, x + 1, y - 1, c, ch, w, h) >= center { - 425●
lbp_val = lbp_val | 4 - 426
} - 427●
if get_pixel_safe_16(src, x + 1, y, c, ch, w, h) >= center { - 428●
lbp_val = lbp_val | 8 - 429
} - 430●
if get_pixel_safe_16(src, x + 1, y + 1, c, ch, w, h) >= center { - 431●
lbp_val = lbp_val | 16 - 432
} - 433●
if get_pixel_safe_16(src, x, y + 1, c, ch, w, h) >= center { - 434●
lbp_val = lbp_val | 32 - 435
} - 436●
if get_pixel_safe_16(src, x - 1, y + 1, c, ch, w, h) >= center { - 437●
lbp_val = lbp_val | 64 - 438
} - 439●
if get_pixel_safe_16(src, x - 1, y, c, ch, w, h) >= center { - 440●
lbp_val = lbp_val | 128 - 441
} - 442●
write_u16_le_l(out, (y * w + x) * bpp + c * 2, uniform_lbp_map(lbp_val)) - 443
} - 444
} - 445
} - 446
if ch == 4 { - 447○
for i in 0..<n { - 448○
let alpha_off = i * bpp + 6 - 449
out[alpha_off] = img.data[alpha_off] - 450
out[alpha_off + 1] = img.data[alpha_off + 1] - 451
} - 452
} - 453
@types.Image16::{ - 454
width: w, - 455
height: h, - 456
channels: ch, - 457●
data: Bytes::from_array(out), - 458
} - 459
} - 460
- 461
///| - 462
/// float 均匀局部二值模式(Uniform LBP)。输出归一化到 0.0-1.0(标签/9)。 - 463
/// @see lbp_uniform 8-bit 版本,本函数为 ImageF 变体 - 464
pub fn lbp_uniform_f( - 465
img : @types.ImageF, - 466
) -> @types.ImageF raise @types.LoadError { - 467
// 输入验证 - 468●
if img.width <= 0 || img.height <= 0 { - 469●
raise @types.LoadError::DecodeFailed( - 470
"lbp_uniform_f: 图像尺寸必须大于0", - 471
) - 472
} - 473
if img.channels != 1 && img.channels != 3 && img.channels != 4 { - 474○
raise @types.LoadError::DecodeFailed( - 475
"lbp_uniform_f: 仅支持 channels=1/3/4", - 476
) - 477
} - 478
let expected_size = img.width * img.height * img.channels * 4 - 479●
if img.data.length() != expected_size { - 480●
raise @types.LoadError::DecodeFailed( - 481
"lbp_uniform_f: 数据大小不匹配,期望 " + - 482●
expected_size.to_string() + - 483
",实际 " + - 484●
img.data.length().to_string(), - 485
) - 486
} - 487
let ch = img.channels - 488◐
let color_ch = if ch >= 3 { 3 } else { 1 } - 489
let w = img.width - 490
let h = img.height - 491
let n = w * h - 492
let bpp = ch * 4 - 493●
let out : Array[Byte] = Array::make(n * bpp, b'\x00') - 494●
let src : Array[Float] = Array::make(n * ch, 0.0F) - 495
for i in 0..<(n * ch) { - 496●
src[i] = read_float_le_l(img.data, i * 4) - 497
} - 498
for c in 0..<color_ch { - 499●
for y in 1..<(h - 1) { - 500●
for x in 1..<(w - 1) { - 501●
let center = src[(y * w + x) * ch + c] - 502
let mut lbp_val = 0 - 503
if src[((y - 1) * w + (x - 1)) * ch + c] >= center { - 504●
lbp_val = lbp_val | 1 - 505
} - 506
if src[((y - 1) * w + x) * ch + c] >= center { - 507●
lbp_val = lbp_val | 2 - 508
} - 509
if src[((y - 1) * w + (x + 1)) * ch + c] >= center { - 510●
lbp_val = lbp_val | 4 - 511
} - 512
if src[(y * w + (x + 1)) * ch + c] >= center { - 513●
lbp_val = lbp_val | 8 - 514
} - 515
if src[((y + 1) * w + (x + 1)) * ch + c] >= center { - 516●
lbp_val = lbp_val | 16 - 517
} - 518
if src[((y + 1) * w + x) * ch + c] >= center { - 519●
lbp_val = lbp_val | 32 - 520
} - 521
if src[((y + 1) * w + (x - 1)) * ch + c] >= center { - 522●
lbp_val = lbp_val | 64 - 523
} - 524
if src[(y * w + (x - 1)) * ch + c] >= center { - 525●
lbp_val = lbp_val | 128 - 526
} - 527●
let label = uniform_lbp_map(lbp_val) - 528●
write_f32_le_l( - 529
out, - 530
(y * w + x) * bpp + c * 4, - 531●
Float::from_int(label) / 9.0F, - 532
) - 533
} - 534
} - 535
for y in 0..<h { - 536●
let y_inner = y >= 1 && y < h - 1 - 537
for x in 0..<w { - 538●
if y_inner && x >= 1 && x < w - 1 { - 539●
continue - 540
} - 541
let center = src[(y * w + x) * ch + c] - 542
let mut lbp_val = 0 - 543●
if get_pixel_safe_f(src, x - 1, y - 1, c, ch, w, h) >= center { - 544●
lbp_val = lbp_val | 1 - 545
} - 546●
if get_pixel_safe_f(src, x, y - 1, c, ch, w, h) >= center { - 547●
lbp_val = lbp_val | 2 - 548
} - 549●
if get_pixel_safe_f(src, x + 1, y - 1, c, ch, w, h) >= center { - 550●
lbp_val = lbp_val | 4 - 551
} - 552●
if get_pixel_safe_f(src, x + 1, y, c, ch, w, h) >= center { - 553●
lbp_val = lbp_val | 8 - 554
} - 555●
if get_pixel_safe_f(src, x + 1, y + 1, c, ch, w, h) >= center { - 556●
lbp_val = lbp_val | 16 - 557
} - 558●
if get_pixel_safe_f(src, x, y + 1, c, ch, w, h) >= center { - 559●
lbp_val = lbp_val | 32 - 560
} - 561●
if get_pixel_safe_f(src, x - 1, y + 1, c, ch, w, h) >= center { - 562●
lbp_val = lbp_val | 64 - 563
} - 564●
if get_pixel_safe_f(src, x - 1, y, c, ch, w, h) >= center { - 565●
lbp_val = lbp_val | 128 - 566
} - 567●
let label = uniform_lbp_map(lbp_val) - 568●
write_f32_le_l( - 569
out, - 570
(y * w + x) * bpp + c * 4, - 571●
Float::from_int(label) / 9.0F, - 572
) - 573
} - 574
} - 575
} - 576
if ch == 4 { - 577○
for i in 0..<n { - 578○
let alpha_off = i * bpp + 12 - 579
for b in 0..<4 { - 580○
out[alpha_off + b] = img.data[alpha_off + b] - 581
} - 582
} - 583
} - 584
@types.ImageF::{ - 585
width: w, - 586
height: h, - 587
channels: ch, - 588●
data: Bytes::from_array(out), - 589
} - 590
}