how crop an image automatically without any coordinate?
2 ビュー (過去 30 日間)
古いコメントを表示
Dayangku Nur Faizah Pengiran Mohamad
2024 年 5 月 12 日
コメント済み: Image Analyst
2024 年 5 月 17 日
Hello everyone. My original image width 841pixels x height 482 pixels. So, the problem here's, I want to crop the image automatically with 512x512 pixels in the center of the lesion like the picture above. but my original image does not enough pixels to crop. Should I enlarge the original image first? What I meant is that, the pixels from the original image is enlarge from the original one. So, my objective have 2, first : if the orignal image does not enough pixels crop, I want Matlab to enlarge the pixels of the original image at first, then crop automatically into 512x512 pixels. Here, I attacth the image that I want to crop using square box. As you can see below picture, the square box detects the lesion ground truth below and crop it automatically. and also the original image I attached below.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1692796/image.png)
Hope that you can help me out. Thank you.
0 件のコメント
採用された回答
Image Analyst
2024 年 5 月 12 日
18 件のコメント
Dayangku Nur Faizah Pengiran Mohamad
2024 年 5 月 17 日
編集済み: Dayangku Nur Faizah Pengiran Mohamad
2024 年 5 月 17 日
Image Analyst
2024 年 5 月 17 日
Wow, so much wrong with that code! For one thing, don't use size as the name of your variable since it's the name of a very important built-in function. In fact you later try to use it as the built-in function to get the size of your image but since you overrode the function with your variable, it will use the variable "size" instead of the function size(). Not only that but if you were using the size function, you're using it incorrectly. JPG images are often RGB even if they appear gray scale. So you'd need to do
[rows, columns, numberOfColorChannels] = size(yourImage);
which brings up to yet another problem. "image" is also the name of a built in function so you should not use it for the name of your variable. Call in inputImage instead of image.
See Steve's blog: Too much information about the size function | Steve on Image Processing
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Image Processing and Computer Vision についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!