iT邦幫忙

2023 iThome 鐵人賽

DAY 3
0
自我挑戰組

多媒體:影像處理系列 第 3

取得影像資訊

  • 分享至 

  • xImage
  •  

我們使用javax.imageio.ImageIO類別的read方法,獲得回傳BufferedImage Object.
代表此物件已經載入記憶體緩衝區的影像檔。

接下來我們用三個方法來取得相關的影像資訊:

  • 取得JDK原生支援影像格式
public void getReadWriteFormat(){
        String[] readSuffixes = ImageIO.getReaderFileSuffixes(); //讀取檔案格式副檔名
        String[] writeSuffixes = ImageIO.getWriterFileSuffixes(); //寫入檔案格式副檔名

        String canReadFormat = "";
        String canWriteFormat = "";

        for(int i=0 ; i<readSuffixes.length ; i++)
            canReadFormat += readSuffixes[i]+",";
        for(int i=0 ; i< writeSuffixes.length ; i++)
            canWriteFormat += writeSuffixes[i]+",";

        //去除最後一個逗點
        canReadFormat = canReadFormat.substring(0, canReadFormat.length()-1);
        canWriteFormat = canWriteFormat.substring(0, canWriteFormat.length()-1);

        System.out.println("JDK支援對"+ canReadFormat +"格式讀取");
        System.out.println("JDK支援對"+ canWriteFormat +"格式寫入");
    }
  • Color Space
    private String getColorSpaceName(int type) {
        String name = "";   //先設定字串空白,方便接下來使用
        switch(type){
            case 0:
                name = "TYPE_XYZ";
                break;
            case 1:
                name = "TYPE_Lab";
                break;
            case 2:
                name = "TYPE_Luv";
                break;
            case 3:
                name = "TYPE_YCbCr";
                break;
            case 4:
                name = "TYPE_Yxy";
                break;
            case 5:
                name = "TYPE_RGB";
                break;
            case 6:
                name = "TYPE_GRAY";
                break;
            case 7:
                name = "TYPE_HSV";
                break;
            case 8:
                name = "TYPE_HLS";
                break;
            case 9:
                name = "TYPE_CMYK";
                break;
            case 11:
                name = "TYPE_CMY";
                break;
        }
        return name;
    }

下圖為 Plan views of RGB gamut in (A) YUV, (B) YIQ and (C) YCbCR colour spaces. In YCbCr the screen primaries are evenly spaced, as in the RGB-CMY hue circle, though in the reverse order.

  • 透明度
private String getTransparencyName(int type){
        String name = "";
        switch(type){
            case 1:
                name = "OPAQUE, 完全不透明, 所有像素的Alpha值都為1.0";
                break;
            case 2:
                name = "BITMASK, 完全不透明(Alpha值都為1.0) or 完全透明(Alpha值都為0.0)";
                break;
            case 3:
                name = "TRANSLUCENT, Alpha值為0.0~1.0 (含兩者)";
                break;
        }
        return name;
    }

Value-by-alpha maps | Andy Woodruff


參考資料:深智數位《CV+AI自己動手完成圖像搜尋引擎》
The Dimensions of Colour, CIE LAB, CIE LUV YCbCr
Value-by-alpha maps | Andy Woodruff


上一篇
電腦如何取得、表示影像2
下一篇
影像特徵
系列文
多媒體:影像處理30
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言