我在做一个基于内容的图片检索系统,现在提取了一个颜色特征一维数组h[k]  0<=k<=255
每幅图片都有一个特征需要存入。
而同时还要另外建一个表将图片的文件头信息和像素数据分开存入
将指针定位到像素起始位置后怎么将整个像素数据格式为二进制流然后存入?
而特征数组怎么存入,也是格式为二进制存入吗?怎么格式化?
请大家不吝赐教

解决方案 »

  1.   

    换个地方问吧 ,VC这东西,你应该到VC数据库地方问一下~
      

  2.   

    sql用image类型,vc中ado用safearray方式存取,网上一搜一把例子的
      

  3.   

    我以前做过类似的图像检索咚咚,是VC+Oracle9i。首先建立一个基本表,其中的字段包含图像文件的基本信息,比如文件名、大小、高度宽度、格式等等,当然还有一个最重要的字段,我当时使用Blob字段存储的图像。然后针对一幅图像或一批图像进行处理,用MFC的文件信息分割类分别读取文件的基本信息,分别存储到基本字段里,再将图像存储到Blob字段里。Try it!p.s.过一会儿给你点代码,和和
      

  4.   

    LeiShi(leizi) ( ) 信誉:100 我也想要可以给我看看吗??
    先谢谢了。
      

  5.   

    这是以前写过项目的一个函数,提取strPathName路径图像文件的信息,自己研究一下吧。
    void CInfoFormView::SaveInfo(LPCSTR strPathName)
    {
    CFile imagefile; VARIANT varBLOB;
    BYTE* pbuf; long nLength;
    long nMaxID; char drive[_MAX_DRIVE];   
    char dir[_MAX_DIR];
    char fname[_MAX_FNAME];   
    char ext[_MAX_EXT]; _splitpath(strPathName, drive, dir, fname, ext); if (!stricmp(ext, ".bmp"))   
    {
    strcpy(ext, ".bmp");
    pImage = new CImageBmp;
    pImage->ReadFile(strPathName, &nLength);
    }
    if (!stricmp(ext, ".gif"))    
    {
    strcpy(ext, ".gif");
    pImage = new CImageGif;
    pImage->ReadFile(strPathName, &nLength);
    }
    if (!stricmp(ext, ".jpg") || !stricmp(ext,".jpeg"))   
    {
    strcpy(ext, ".jpg");
    pImage = new CImageJpg;
    pImage->ReadFile(strPathName, &nLength);
    } try
    {
    theApp.m_pRecordset->Close();
    CString str = "select * from tbl_image";
    _bstr_t bstrQuery = str;
    theApp.m_pRecordset->Open(bstrQuery, _variant_t((IDispatch *)theApp.m_pConnection, true), adOpenDynamic, adLockOptimistic, adCmdText); theApp.m_pRecordset->MoveLast();
    nMaxID = (long)theApp.m_pRecordset->Fields->GetItem("ID")->Value;
    theApp.m_pRecordset->AddNew(); theApp.m_pRecordset->Fields->GetItem("ID")->Value = (_variant_t)(long)(nMaxID+1);
    theApp.m_pRecordset->Fields->GetItem("NAME")->Value = (_bstr_t)fname;
    theApp.m_pRecordset->Fields->GetItem("WIDTH")->Value = (_variant_t)(long)(pImage->DIBWidth());
    theApp.m_pRecordset->Fields->GetItem("HEIGHT")->Value = (_variant_t)(long)(pImage->DIBHeight());
    theApp.m_pRecordset->Fields->GetItem("CONTENTLENGTH")->Value = (_variant_t)nLength;
    theApp.m_pRecordset->Fields->GetItem("MIMETYPE")->Value = (_bstr_t)ext; delete pImage; if(0 == imagefile.Open(strPathName, CFile::modeRead))
    return; pbuf = new BYTE[nLength + 2];
    if(pbuf == NULL)
    return; imagefile.Read(pbuf, nLength); BYTE *pBufEx;
    pBufEx = pbuf; SAFEARRAY *psa;
    SAFEARRAYBOUND rgsabound[1]; rgsabound[0].lLbound = 0;
    rgsabound[0].cElements = nLength; psa = SafeArrayCreate(VT_UI1, 1, rgsabound); for (long i = 0; i < nLength; i++)
    SafeArrayPutElement(psa, &i, pBufEx++); varBLOB.vt = VT_ARRAY | VT_UI1;
    varBLOB.parray = psa; theApp.m_pRecordset->Fields->GetItem("IMAGE_BLOB")->AppendChunk(varBLOB);

    theApp.m_pRecordset->Update(); theApp.m_pRecordset->Requery(adCmdText); ContentBuild();
    }
    catch(_com_error e)
    {
    _bstr_t bstrSource(e.Source());
    _bstr_t bstrDescription(e.Description());
    CString sError;
    sError.Format("Source : %s \n Description : %s\n", (LPCSTR)bstrSource, (LPCSTR)bstrDescription);
    AfxMessageBox(sError);
    }
    }Try it!
      

  6.   

    补充,这里的CImageGif,CImageJpg,CImageBmp都是我自定义的图像操作类