image.process\transform\seam_carving_16f.mbt

96.2% · 175 / 182 points · 556 lines

Background color reports the state of each line. Underlined characters mark exact instrumented byte offsets; hover them to inspect the visit count.

  1. 1///|
  2. 2/// # Seam Carving 16f seam carving 16f
  3. 3///
  4. 4/// 图像处理算法模块
  5. 5/// 图像处理算法模块 Image processing algorithm module
  6. 6// 接缝裁剪(Seam Carving)16-bit/float 变体
  7. 7
  8. 8///|
  9. 9/// 计算图像能量图 16-bit 版本
  10. 10/// @see compute_energy 8-bit 版本,本函数为 Image16 变体
  11. 11pub fn compute_energy_16(img : @types.Image16) -> Array[Double] {
  12. 12● let w = img.width
  13. 13 let h = img.height
  14. 14 let ch = img.channels
  15. 15● let energy = Array::make(w * h, 0.0)
  16. 16 for y in 0..<h {
  17. 17● for x in 0..<w {
  18. 18● let ym = if y == 0 { 0 } else { y - 1 }
  19. 19● let yp = if y == h - 1 { h - 1 } else { y + 1 }
  20. 20● let xm = if x == 0 { 0 } else { x - 1 }
  21. 21● let xp = if x == w - 1 { w - 1 } else { x + 1 }
  22. 22 let mut gx = 0.0
  23. 23 let mut gy = 0.0
  24. 24 for c in 0..<ch {
  25. 25● let left = img.data[((y * w + xm) * ch + c) * 2].to_int() |
  26. 26● (img.data[((y * w + xm) * ch + c) * 2 + 1].to_int() << 8)
  27. 27● let right = img.data[((y * w + xp) * ch + c) * 2].to_int() |
  28. 28● (img.data[((y * w + xp) * ch + c) * 2 + 1].to_int() << 8)
  29. 29● let top = img.data[((ym * w + x) * ch + c) * 2].to_int() |
  30. 30● (img.data[((ym * w + x) * ch + c) * 2 + 1].to_int() << 8)
  31. 31● let bottom = img.data[((yp * w + x) * ch + c) * 2].to_int() |
  32. 32● (img.data[((yp * w + x) * ch + c) * 2 + 1].to_int() << 8)
  33. 33● gx += (right - left).to_double()
  34. 34● gy += (bottom - top).to_double()
  35. 35 }
  36. 36● let abs_gx = if gx < 0.0 { -gx } else { gx }
  37. 37● let abs_gy = if gy < 0.0 { -gy } else { gy }
  38. 38 energy[y * w + x] = abs_gx + abs_gy
  39. 39 }
  40. 40 }
  41. 41 energy
  42. 42}
  43. 43
  44. 44///|
  45. 45/// 计算图像能量图 float 版本
  46. 46/// @see compute_energy 8-bit 版本,本函数为 ImageF 变体
  47. 47pub fn compute_energy_f(img : @types.ImageF) -> Array[Double] {
  48. 48● let w = img.width
  49. 49 let h = img.height
  50. 50 let ch = img.channels
  51. 51● let energy = Array::make(w * h, 0.0)
  52. 52 for y in 0..<h {
  53. 53● for x in 0..<w {
  54. 54● let ym = if y == 0 { 0 } else { y - 1 }
  55. 55● let yp = if y == h - 1 { h - 1 } else { y + 1 }
  56. 56● let xm = if x == 0 { 0 } else { x - 1 }
  57. 57● let xp = if x == w - 1 { w - 1 } else { x + 1 }
  58. 58 let mut gx = 0.0
  59. 59 let mut gy = 0.0
  60. 60 for c in 0..<ch {
  61. 61● let left_bits = img.data[((y * w + xm) * ch + c) * 4].to_int() |
  62. 62● (img.data[((y * w + xm) * ch + c) * 4 + 1].to_int() << 8) |
  63. 63● (img.data[((y * w + xm) * ch + c) * 4 + 2].to_int() << 16) |
  64. 64● (img.data[((y * w + xm) * ch + c) * 4 + 3].to_int() << 24)
  65. 65● let right_bits = img.data[((y * w + xp) * ch + c) * 4].to_int() |
  66. 66● (img.data[((y * w + xp) * ch + c) * 4 + 1].to_int() << 8) |
  67. 67● (img.data[((y * w + xp) * ch + c) * 4 + 2].to_int() << 16) |
  68. 68● (img.data[((y * w + xp) * ch + c) * 4 + 3].to_int() << 24)
  69. 69● let top_bits = img.data[((ym * w + x) * ch + c) * 4].to_int() |
  70. 70● (img.data[((ym * w + x) * ch + c) * 4 + 1].to_int() << 8) |
  71. 71● (img.data[((ym * w + x) * ch + c) * 4 + 2].to_int() << 16) |
  72. 72● (img.data[((ym * w + x) * ch + c) * 4 + 3].to_int() << 24)
  73. 73● let bottom_bits = img.data[((yp * w + x) * ch + c) * 4].to_int() |
  74. 74● (img.data[((yp * w + x) * ch + c) * 4 + 1].to_int() << 8) |
  75. 75● (img.data[((yp * w + x) * ch + c) * 4 + 2].to_int() << 16) |
  76. 76● (img.data[((yp * w + x) * ch + c) * 4 + 3].to_int() << 24)
  77. 77● let left = Float::reinterpret_from_int(left_bits)
  78. 78● let right = Float::reinterpret_from_int(right_bits)
  79. 79● let top = Float::reinterpret_from_int(top_bits)
  80. 80● let bottom = Float::reinterpret_from_int(bottom_bits)
  81. 81● gx += (right - left).to_double()
  82. 82● gy += (bottom - top).to_double()
  83. 83 }
  84. 84● let abs_gx = if gx < 0.0 { -gx } else { gx }
  85. 85● let abs_gy = if gy < 0.0 { -gy } else { gy }
  86. 86 energy[y * w + x] = abs_gx + abs_gy
  87. 87 }
  88. 88 }
  89. 89 energy
  90. 90}
  91. 91
  92. 92///|
  93. 93/// 移除垂直 seam 16-bit 版本
  94. 94/// @see remove_vertical_seam 8-bit 版本,本函数为 Image16 变体
  95. 95pub fn remove_vertical_seam_16(
  96. 96 img : @types.Image16,
  97. 97 seam : Array[Int32],
  98. 98) -> @types.Image16 {
  99. 99● let w = img.width
  100. 100 let h = img.height
  101. 101 let ch = img.channels
  102. 102 let new_w = w - 1
  103. 103● let out : Array[Byte] = Array::make(new_w * h * ch * 2, b'\x00')
  104. 104 for y in 0..<h {
  105. 105● let seam_x = seam[y]
  106. 106 for x in 0..<seam_x {
  107. 107● for c in 0..<ch {
  108. 108● out[((y * new_w + x) * ch + c) * 2] = img.data[((y * w + x) * ch + c) *
  109. 109 2]
  110. 110 out[((y * new_w + x) * ch + c) * 2 + 1] = img.data[(
  111. 111 (y * w + x) * ch + c
  112. 112 ) *
  113. 113 2 +
  114. 114 1]
  115. 115 }
  116. 116 }
  117. 117 for x in seam_x..<new_w {
  118. 118● for c in 0..<ch {
  119. 119● out[((y * new_w + x) * ch + c) * 2] = img.data[(
  120. 120 (y * w + x + 1) * ch + c
  121. 121 ) *
  122. 122 2]
  123. 123 out[((y * new_w + x) * ch + c) * 2 + 1] = img.data[(
  124. 124 (y * w + x + 1) * ch + c
  125. 125 ) *
  126. 126 2 +
  127. 127 1]
  128. 128 }
  129. 129 }
  130. 130 }
  131. 131 @types.Image16::{
  132. 132 width: new_w,
  133. 133 height: h,
  134. 134 channels: ch,
  135. 135● data: Bytes::from_array(out),
  136. 136 }
  137. 137}
  138. 138
  139. 139///|
  140. 140/// 移除垂直 seam float 版本
  141. 141/// @see remove_vertical_seam 8-bit 版本,本函数为 ImageF 变体
  142. 142pub fn remove_vertical_seam_f(
  143. 143 img : @types.ImageF,
  144. 144 seam : Array[Int32],
  145. 145) -> @types.ImageF {
  146. 146● let w = img.width
  147. 147 let h = img.height
  148. 148 let ch = img.channels
  149. 149 let new_w = w - 1
  150. 150● let out : Array[Byte] = Array::make(new_w * h * ch * 4, b'\x00')
  151. 151 for y in 0..<h {
  152. 152● let seam_x = seam[y]
  153. 153 for x in 0..<seam_x {
  154. 154● for c in 0..<ch {
  155. 155● for b in 0..<4 {
  156. 156● out[((y * new_w + x) * ch + c) * 4 + b] = img.data[(
  157. 157 (y * w + x) * ch + c
  158. 158 ) *
  159. 159 4 +
  160. 160 b]
  161. 161 }
  162. 162 }
  163. 163 }
  164. 164 for x in seam_x..<new_w {
  165. 165● for c in 0..<ch {
  166. 166● for b in 0..<4 {
  167. 167● out[((y * new_w + x) * ch + c) * 4 + b] = img.data[(
  168. 168 (y * w + x + 1) * ch + c
  169. 169 ) *
  170. 170 4 +
  171. 171 b]
  172. 172 }
  173. 173 }
  174. 174 }
  175. 175 }
  176. 176 @types.ImageF::{
  177. 177 width: new_w,
  178. 178 height: h,
  179. 179 channels: ch,
  180. 180● data: Bytes::from_array(out),
  181. 181 }
  182. 182}
  183. 183
  184. 184///|
  185. 185/// 移除水平 seam 16-bit 版本
  186. 186/// @see remove_horizontal_seam 8-bit 版本,本函数为 Image16 变体
  187. 187pub fn remove_horizontal_seam_16(
  188. 188 img : @types.Image16,
  189. 189 seam : Array[Int32],
  190. 190) -> @types.Image16 {
  191. 191● let w = img.width
  192. 192 let h = img.height
  193. 193 let ch = img.channels
  194. 194 let new_h = h - 1
  195. 195● let out : Array[Byte] = Array::make(w * new_h * ch * 2, b'\x00')
  196. 196 for x in 0..<w {
  197. 197● let seam_y = seam[x]
  198. 198 for y in 0..<seam_y {
  199. 199● for c in 0..<ch {
  200. 200● out[((y * w + x) * ch + c) * 2] = img.data[((y * w + x) * ch + c) * 2]
  201. 201 out[((y * w + x) * ch + c) * 2 + 1] = img.data[((y * w + x) * ch + c) *
  202. 202 2 +
  203. 203 1]
  204. 204 }
  205. 205 }
  206. 206 for y in seam_y..<new_h {
  207. 207● for c in 0..<ch {
  208. 208● out[((y * w + x) * ch + c) * 2] = img.data[(((y + 1) * w + x) * ch + c) *
  209. 209 2]
  210. 210 out[((y * w + x) * ch + c) * 2 + 1] = img.data[(
  211. 211 ((y + 1) * w + x) * ch + c
  212. 212 ) *
  213. 213 2 +
  214. 214 1]
  215. 215 }
  216. 216 }
  217. 217 }
  218. 218 @types.Image16::{
  219. 219 width: w,
  220. 220 height: new_h,
  221. 221 channels: ch,
  222. 222● data: Bytes::from_array(out),
  223. 223 }
  224. 224}
  225. 225
  226. 226///|
  227. 227/// 移除水平 seam float 版本
  228. 228/// @see remove_horizontal_seam 8-bit 版本,本函数为 ImageF 变体
  229. 229pub fn remove_horizontal_seam_f(
  230. 230 img : @types.ImageF,
  231. 231 seam : Array[Int32],
  232. 232) -> @types.ImageF {
  233. 233● let w = img.width
  234. 234 let h = img.height
  235. 235 let ch = img.channels
  236. 236 let new_h = h - 1
  237. 237● let out : Array[Byte] = Array::make(w * new_h * ch * 4, b'\x00')
  238. 238 for x in 0..<w {
  239. 239● let seam_y = seam[x]
  240. 240 for y in 0..<seam_y {
  241. 241● for c in 0..<ch {
  242. 242● for b in 0..<4 {
  243. 243● out[((y * w + x) * ch + c) * 4 + b] = img.data[((y * w + x) * ch + c) *
  244. 244 4 +
  245. 245 b]
  246. 246 }
  247. 247 }
  248. 248 }
  249. 249 for y in seam_y..<new_h {
  250. 250● for c in 0..<ch {
  251. 251● for b in 0..<4 {
  252. 252● out[((y * w + x) * ch + c) * 4 + b] = img.data[(
  253. 253 ((y + 1) * w + x) * ch + c
  254. 254 ) *
  255. 255 4 +
  256. 256 b]
  257. 257 }
  258. 258 }
  259. 259 }
  260. 260 }
  261. 261 @types.ImageF::{
  262. 262 width: w,
  263. 263 height: new_h,
  264. 264 channels: ch,
  265. 265● data: Bytes::from_array(out),
  266. 266 }
  267. 267}
  268. 268
  269. 269///|
  270. 270/// 插入垂直 seam 16-bit 版本
  271. 271fn insert_vertical_seam_16(
  272. 272 img : @types.Image16,
  273. 273 seam : Array[Int32],
  274. 274) -> @types.Image16 {
  275. 275● let w = img.width
  276. 276 let h = img.height
  277. 277 let ch = img.channels
  278. 278 let new_w = w + 1
  279. 279● let out : Array[Byte] = Array::make(new_w * h * ch * 2, b'\x00')
  280. 280 for y in 0..<h {
  281. 281● let seam_x = seam[y]
  282. 282 for x in 0..<seam_x {
  283. 283○ for c in 0..<ch {
  284. 284○ out[((y * new_w + x) * ch + c) * 2] = img.data[((y * w + x) * ch + c) *
  285. 285 2]
  286. 286 out[((y * new_w + x) * ch + c) * 2 + 1] = img.data[(
  287. 287 (y * w + x) * ch + c
  288. 288 ) *
  289. 289 2 +
  290. 290 1]
  291. 291 }
  292. 292 }
  293. 293 for c in 0..<ch {
  294. 294● out[((y * new_w + seam_x) * ch + c) * 2] = img.data[(
  295. 295 (y * w + seam_x) * ch + c
  296. 296 ) *
  297. 297 2]
  298. 298 out[((y * new_w + seam_x) * ch + c) * 2 + 1] = img.data[(
  299. 299 (y * w + seam_x) * ch + c
  300. 300 ) *
  301. 301 2 +
  302. 302 1]
  303. 303 }
  304. 304 for x in seam_x..<w {
  305. 305● for c in 0..<ch {
  306. 306● out[((y * new_w + x + 1) * ch + c) * 2] = img.data[(
  307. 307 (y * w + x) * ch + c
  308. 308 ) *
  309. 309 2]
  310. 310 out[((y * new_w + x + 1) * ch + c) * 2 + 1] = img.data[(
  311. 311 (y * w + x) * ch + c
  312. 312 ) *
  313. 313 2 +
  314. 314 1]
  315. 315 }
  316. 316 }
  317. 317 }
  318. 318 @types.Image16::{
  319. 319 width: new_w,
  320. 320 height: h,
  321. 321 channels: ch,
  322. 322● data: Bytes::from_array(out),
  323. 323 }
  324. 324}
  325. 325
  326. 326///|
  327. 327/// 插入垂直 seam float 版本
  328. 328fn insert_vertical_seam_f(
  329. 329 img : @types.ImageF,
  330. 330 seam : Array[Int32],
  331. 331) -> @types.ImageF {
  332. 332● let w = img.width
  333. 333 let h = img.height
  334. 334 let ch = img.channels
  335. 335 let new_w = w + 1
  336. 336● let out : Array[Byte] = Array::make(new_w * h * ch * 4, b'\x00')
  337. 337 for y in 0..<h {
  338. 338● let seam_x = seam[y]
  339. 339 for x in 0..<seam_x {
  340. 340○ for c in 0..<ch {
  341. 341○ for b in 0..<4 {
  342. 342○ out[((y * new_w + x) * ch + c) * 4 + b] = img.data[(
  343. 343 (y * w + x) * ch + c
  344. 344 ) *
  345. 345 4 +
  346. 346 b]
  347. 347 }
  348. 348 }
  349. 349 }
  350. 350 for c in 0..<ch {
  351. 351● for b in 0..<4 {
  352. 352● out[((y * new_w + seam_x) * ch + c) * 4 + b] = img.data[(
  353. 353 (y * w + seam_x) * ch + c
  354. 354 ) *
  355. 355 4 +
  356. 356 b]
  357. 357 }
  358. 358 }
  359. 359 for x in seam_x..<w {
  360. 360● for c in 0..<ch {
  361. 361● for b in 0..<4 {
  362. 362● out[((y * new_w + x + 1) * ch + c) * 4 + b] = img.data[(
  363. 363 (y * w + x) * ch + c
  364. 364 ) *
  365. 365 4 +
  366. 366 b]
  367. 367 }
  368. 368 }
  369. 369 }
  370. 370 }
  371. 371 @types.ImageF::{
  372. 372 width: new_w,
  373. 373 height: h,
  374. 374 channels: ch,
  375. 375● data: Bytes::from_array(out),
  376. 376 }
  377. 377}
  378. 378
  379. 379///|
  380. 380/// 插入水平 seam 16-bit 版本
  381. 381fn insert_horizontal_seam_16(
  382. 382 img : @types.Image16,
  383. 383 seam : Array[Int32],
  384. 384) -> @types.Image16 {
  385. 385● let w = img.width
  386. 386 let h = img.height
  387. 387 let ch = img.channels
  388. 388 let new_h = h + 1
  389. 389● let out : Array[Byte] = Array::make(w * new_h * ch * 2, b'\x00')
  390. 390 for x in 0..<w {
  391. 391● let seam_y = seam[x]
  392. 392 for y in 0..<seam_y {
  393. 393○ for c in 0..<ch {
  394. 394○ out[((y * w + x) * ch + c) * 2] = img.data[((y * w + x) * ch + c) * 2]
  395. 395 out[((y * w + x) * ch + c) * 2 + 1] = img.data[((y * w + x) * ch + c) *
  396. 396 2 +
  397. 397 1]
  398. 398 }
  399. 399 }
  400. 400 for c in 0..<ch {
  401. 401● out[((seam_y * w + x) * ch + c) * 2] = img.data[(
  402. 402 (seam_y * w + x) * ch + c
  403. 403 ) *
  404. 404 2]
  405. 405 out[((seam_y * w + x) * ch + c) * 2 + 1] = img.data[(
  406. 406 (seam_y * w + x) * ch + c
  407. 407 ) *
  408. 408 2 +
  409. 409 1]
  410. 410 }
  411. 411 for y in seam_y..<h {
  412. 412● for c in 0..<ch {
  413. 413● out[(((y + 1) * w + x) * ch + c) * 2] = img.data[((y * w + x) * ch + c) *
  414. 414 2]
  415. 415 out[(((y + 1) * w + x) * ch + c) * 2 + 1] = img.data[(
  416. 416 (y * w + x) * ch + c
  417. 417 ) *
  418. 418 2 +
  419. 419 1]
  420. 420 }
  421. 421 }
  422. 422 }
  423. 423 @types.Image16::{
  424. 424 width: w,
  425. 425 height: new_h,
  426. 426 channels: ch,
  427. 427● data: Bytes::from_array(out),
  428. 428 }
  429. 429}
  430. 430
  431. 431///|
  432. 432/// 插入水平 seam float 版本
  433. 433fn insert_horizontal_seam_f(
  434. 434 img : @types.ImageF,
  435. 435 seam : Array[Int32],
  436. 436) -> @types.ImageF {
  437. 437● let w = img.width
  438. 438 let h = img.height
  439. 439 let ch = img.channels
  440. 440 let new_h = h + 1
  441. 441● let out : Array[Byte] = Array::make(w * new_h * ch * 4, b'\x00')
  442. 442 for x in 0..<w {
  443. 443● let seam_y = seam[x]
  444. 444 for y in 0..<seam_y {
  445. 445● for c in 0..<ch {
  446. 446● for b in 0..<4 {
  447. 447● out[((y * w + x) * ch + c) * 4 + b] = img.data[((y * w + x) * ch + c) *
  448. 448 4 +
  449. 449 b]
  450. 450 }
  451. 451 }
  452. 452 }
  453. 453 for c in 0..<ch {
  454. 454● for b in 0..<4 {
  455. 455● out[((seam_y * w + x) * ch + c) * 4 + b] = img.data[(
  456. 456 (seam_y * w + x) * ch + c
  457. 457 ) *
  458. 458 4 +
  459. 459 b]
  460. 460 }
  461. 461 }
  462. 462 for y in seam_y..<h {
  463. 463● for c in 0..<ch {
  464. 464● for b in 0..<4 {
  465. 465● out[(((y + 1) * w + x) * ch + c) * 4 + b] = img.data[(
  466. 466 (y * w + x) * ch + c
  467. 467 ) *
  468. 468 4 +
  469. 469 b]
  470. 470 }
  471. 471 }
  472. 472 }
  473. 473 }
  474. 474 @types.ImageF::{
  475. 475 width: w,
  476. 476 height: new_h,
  477. 477 channels: ch,
  478. 478● data: Bytes::from_array(out),
  479. 479 }
  480. 480}
  481. 481
  482. 482///|
  483. 483/// 内容感知缩放 16-bit 版本
  484. 484/// @see seam_carve_resize 8-bit 版本,本函数为 Image16 变体
  485. 485pub fn seam_carve_resize_16(
  486. 486 img : @types.Image16,
  487. 487 new_w : Int32,
  488. 488 new_h : Int32,
  489. 489) -> @types.Image16 raise @types.LoadError {
  490. 490● if new_w <= 0 || new_h <= 0 {
  491. 491● raise @types.LoadError::DecodeFailed("目标尺寸必须为正数")
  492. 492 }
  493. 493 if new_w > img.width * 2 || new_h > img.height * 2 {
  494. 494● raise @types.LoadError::DecodeFailed("放大不能超过原尺寸的 2 倍")
  495. 495 }
  496. 496 let mut result = img
  497. 497 while result.width > new_w {
  498. 498● let energy = compute_energy_16(result)
  499. 499● let seam = find_vertical_seam(energy, result.width, result.height)
  500. 500● result = remove_vertical_seam_16(result, seam)
  501. 501 }
  502. 502 while result.width < new_w {
  503. 503● let energy = compute_energy_16(result)
  504. 504● let seam = find_vertical_seam(energy, result.width, result.height)
  505. 505● result = insert_vertical_seam_16(result, seam)
  506. 506 }
  507. 507 while result.height > new_h {
  508. 508● let energy = compute_energy_16(result)
  509. 509● let seam = find_horizontal_seam(energy, result.width, result.height)
  510. 510● result = remove_horizontal_seam_16(result, seam)
  511. 511 }
  512. 512 while result.height < new_h {
  513. 513● let energy = compute_energy_16(result)
  514. 514● let seam = find_horizontal_seam(energy, result.width, result.height)
  515. 515● result = insert_horizontal_seam_16(result, seam)
  516. 516 }
  517. 517 result
  518. 518}
  519. 519
  520. 520///|
  521. 521/// 内容感知缩放 float 版本
  522. 522/// @see seam_carve_resize 8-bit 版本,本函数为 ImageF 变体
  523. 523pub fn seam_carve_resize_f(
  524. 524 img : @types.ImageF,
  525. 525 new_w : Int32,
  526. 526 new_h : Int32,
  527. 527) -> @types.ImageF raise @types.LoadError {
  528. 528● if new_w <= 0 || new_h <= 0 {
  529. 529● raise @types.LoadError::DecodeFailed("目标尺寸必须为正数")
  530. 530 }
  531. 531 if new_w > img.width * 2 || new_h > img.height * 2 {
  532. 532● raise @types.LoadError::DecodeFailed("放大不能超过原尺寸的 2 倍")
  533. 533 }
  534. 534 let mut result = img
  535. 535 while result.width > new_w {
  536. 536● let energy = compute_energy_f(result)
  537. 537● let seam = find_vertical_seam(energy, result.width, result.height)
  538. 538● result = remove_vertical_seam_f(result, seam)
  539. 539 }
  540. 540 while result.width < new_w {
  541. 541● let energy = compute_energy_f(result)
  542. 542● let seam = find_vertical_seam(energy, result.width, result.height)
  543. 543● result = insert_vertical_seam_f(result, seam)
  544. 544 }
  545. 545 while result.height > new_h {
  546. 546● let energy = compute_energy_f(result)
  547. 547● let seam = find_horizontal_seam(energy, result.width, result.height)
  548. 548● result = remove_horizontal_seam_f(result, seam)
  549. 549 }
  550. 550 while result.height < new_h {
  551. 551● let energy = compute_energy_f(result)
  552. 552● let seam = find_horizontal_seam(energy, result.width, result.height)
  553. 553● result = insert_horizontal_seam_f(result, seam)
  554. 554 }
  555. 555 result
  556. 556}