When you say extract do you mean replace the firmware currently running with the factory reset app? Or do you mean you just want to read it to memory?
If it's the first case, you can see apps/waf/bootloader/bootloader.c (since your board doesn't support OTA2, otherwise see apps/waf/ota2_bootloader/ota2_bootloader.c) and figure out how they extract the image and replace the currently running app with the extracted one.
If it's the second case, my guess is that you have to call some filesystem API and get that image chunk by chunk. I can elaborate more if you want.