Repository: opencv
Issue: GpuMat::convertTo( cv::cuda::GpuMat, CV_16FC3); 
Labels: category: gpu/cuda (contrib)

<!--
If you have a question rather than reporting a bug please go to https://forum.opencv.org where you get much faster responses.
If you need further assistance please read [How To Contribute](https://github.com/opencv/opencv/wiki/How_to_contribute).

This is a template helping you to create an issue which can be processed as quickly as possible. This is the bug reporting section for the OpenCV library.
-->

##### System information (version)
<!-- Example
- OpenCV => 4.2
- Operating System / Platform => Windows 64 Bit
- Compiler => Visual Studio 2017
-->

- OpenCV => 4.x (Jan 29, 2024)
- Operating System / Platform => Ubuntu 20.04
- Compiler => gcc-8 

##### Detailed description

GPU convert to CV_16FC3 doesnt work correctly 

##### Steps to reproduce

    std::string imageName ="PATH_TO_IMAGE.jpeg";
    cv::Mat img = cv::imread(imageName);
    cv::Mat img16fc3_cpu; //cpu conversion
    cv::Mat img16fc3_gpu; // gpu conversion result
    cv::cuda::GpuMat gpuimg, gpu_img16fc3;
    gpuimg.upload(img);
    gpuimg.convertTo(gpu_img16fc3, CV_16FC3);
    img.convertTo(img16fc3_cpu, CV_16FC3);
    gpu_img16fc3.download(img16fc3_gpu);
    img16fc3_cpu.convertTo(img16fc3_cpu, CV_32FC3);
    img16fc3_gpu.convertTo(img16fc3_gpu, CV_32FC3);
    cv::imshow ("test fp16 cpu ", img16fc3_cpu/255);
    cv::imshow ("test fp16 gpu ", img16fc3_gpu/255);
    cv::waitKey(0);


##### Issue submission checklist

 - [X] I report the issue, it's not a question
   <!--
   OpenCV team works with forum.opencv.org, Stack Overflow and other communities
   to discuss problems. Tickets with questions without a real issue statement will be
   closed.
   -->
 - [X] I checked the problem with documentation, FAQ, open issues,
       forum.opencv.org, Stack Overflow, etc and have not found any solution
   <!--
   Places to check:
   * OpenCV documentation: https://docs.opencv.org
   * FAQ page: https://github.com/opencv/opencv/wiki/FAQ
   * OpenCV forum: https://forum.opencv.org
   * OpenCV issue tracker: https://github.com/opencv/opencv/issues?q=is%3Aissue
   * Stack Overflow branch: https://stackoverflow.com/questions/tagged/opencv
   -->
 - [X] I updated to the latest OpenCV version and the issue is still there (4.x from Jan29, 2024)
   <!--
   master branch for OpenCV 4.x and 3.4 branch for OpenCV 3.x releases.
   OpenCV team supports only the latest release for each branch.
   The ticket is closed if the problem is not reproduced with the modern version.
   -->
 - [X] There is reproducer code and related data files: videos, images, onnx, etc
   <!--
   The best reproducer -- test case for OpenCV that we can add to the library.
   Recommendations for media files and binary files:
   * Try to reproduce the issue with images and videos in opencv_extra repository
     to reduce attachment size
   * Use PNG for images, if you report some CV related bug, but not image reader
     issue
   * Attach the image as an archive to the ticket, if you report some reader issue.
     Image hosting services compress images and it breaks the repro code.
   * Provide ONNX file for some public model or ONNX file with random weights,
     if you report ONNX parsing or handling issue. Architecture details diagram
     from netron tool can be very useful too. See https://lutzroeder.github.io/netron/
   -->
   
   
![cpu](https://github.com/opencv/opencv/assets/12120066/7064aadc-eb8f-4312-b3ed-04bde08ca156)
![gpu](https://github.com/opencv/opencv/assets/12120066/171e539c-a01a-4b17-9945-17cce742a204)