How to generate RGB for each Pixel in SWIFT?

I'm new to SWIFT, and my project is reading every pixel of an image then return the RGB value for each pixel. I'm able to load the Image from URL. How can I return the Pixel RGB similar to below:

pix 0 rgb 0 118 195

pix 1 rgb 0 119 196

pix 2 rgb 0 118 194

Thank you!

import PlaygroundSupport

class MyViewController : UIViewController {
    override func loadView() {
        let view = UIView()
        view.backgroundColor = .white

        let imageUrlString = "https://sff-koi.com/wp/wp-content/uploads/2021/06/AJKS-2000-32nd-champion-600x840.jpg"
        guard let imageUrl:URL = URL(string: imageUrlString) else {
            return
        }
        
        // Start background thread so that image loading does not make app unresponsive
          DispatchQueue.global().async { [weak self] in
            
            guard let self = self else { return }
            
            guard let imageData = try? Data(contentsOf: imageUrl) else {
                return
            }
   
            let imageView = UIImageView(frame: CGRect(x:0, y:0, width:400, height:400))
            imageView.center = self.view.center
            
            // When from a background thread, UI needs to be updated on main_queue
           DispatchQueue.main.async {
                let image = UIImage(data: imageData)
                imageView.image = image
                imageView.contentMode = UIView.ContentMode.scaleAspectFit
                self.view.addSubview(imageView)
            }
        }
 
        self.view = view
    }
}

// Present the view controller in the Live View window
PlaygroundPage.current.liveView = MyViewController()

If I understand correctly, you want to read the RGB value of a pixel at a certain position in the image.

If so, you will loop on x and y position in the image and read the value as describe here: https://stackoverflow.com/questions/25146557/how-do-i-get-the-color-of-a-pixel-in-a-uiimage-with-swift

How to generate RGB for each Pixel in SWIFT?
 
 
Q