How to Crop Images using OpenCV | Image cropping Python | Computer Vision | Data Magic

Поділитися
Вставка
  • Опубліковано 1 жов 2024

КОМЕНТАРІ • 15

  • @CrimsonQuark
    @CrimsonQuark Рік тому

    how can i crop a fits image using python

    • @DataMagicAI
      @DataMagicAI  Рік тому

      import astropy.io.fits as fits
      from astropy.nddata.utils import Cutout2D
      # Open the FITS image
      fits_image = fits.open('fits_image.fits')[0]
      # Create a Cutout2D object
      cutout = Cutout2D(fits_image, (100, 100), (200, 200))
      # Extract the cropped image
      cropped_image = cutout.cutout()
      # Save the cropped image to a new FITS file
      fits.writeto('cropped_image.fits', cropped_image)

  • @kittypie2011
    @kittypie2011 3 роки тому +1

    Hi your vedio was veryy useful.really tq for this. How should we write the code so that I need to save the cropped images in a folder with a particular name.

    • @DataMagicAI
      @DataMagicAI  3 роки тому

      Thank you ! For your query, Please checkout below episode - ua-cam.com/play/PLTmQbi1PYZ_GrjMHiGCYa0WyDZfxu-yTz.html

  • @danyalasif8322
    @danyalasif8322 10 місяців тому +1

    Thank You Sir!

  • @anastasiaberlianna1743
    @anastasiaberlianna1743 Рік тому

    Hi! Thank you for your video, i have question, if we have large dataset which include some images in it and we want to automatically crop it how we can do that? Since the position of each image may be different. Thanks!

    • @DataMagicAI
      @DataMagicAI  Рік тому

      You can use masking and then crop object using bounding boxes.
      If you not bothered about cropping and want to resize all images to same size the. You can use keras image generators to load images from folders

  • @usmankhawar888
    @usmankhawar888 Рік тому

    My question may irrelevant to your video...
    I can easily open images and work on them but I have no clue how to NOT OPEN IMAGE but when you run your app it asks you to crop any area of current screen and once you crop image by mouse that image saves in the drive and you can work on it. So instead of refrencing image file location (every video has file location reference) you actually crop a portion of the screen and then work on it
    Any idea where to start?
    Thanks

    • @DataMagicAI
      @DataMagicAI  Рік тому +1

      Video is nothing but collection of images in sequence. When you read video in program you actually read the images in sequence from that video. You can write code to crop the each frame/image as per you choice in loop.
      At the end result you will find your video cropped with provided size.

    • @usmankhawar888
      @usmankhawar888 Рік тому

      @@DataMagicAI Thanks for replying...
      I had nothing to do with videos.
      I wanted to know that... is there a workaround that instead of referencing image location like here in this video on line 28 you give location...
      "image = cv2.imread("c:\images\obama\obama1.jpeg")"
      So instead of giving location for image. When we run app it will ask to select (crop) a portion of current screen by mouse and then that portion is cropped and shown

  • @rryann088
    @rryann088 3 роки тому +1

    This helped a lot ! Thanks!

  • @nevikaahuja7188
    @nevikaahuja7188 Рік тому

    Thankyou