- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
int size1; int size2;
ptr1 = new Ipp16u[1392*1024]; ptr2 = new Ipp8u[1392*1024];
Ipp8u *buffer;
Ipp16s *dx, *dy;
dx = new Ipp16s[1392*1024]; dy = new Ipp16s[1392*1024];
readVals(); testMethod(); sts = ippiFilterSobelHorizGetBufferSize_8u16s_C1R(imgSize, ippMskSize3x3, &size1); sts = ippiFilterSobelHorizGetBufferSize_8u16s_C1R(imgSize, ippMskSize3x3, &size2);
if(size1
if(size1 < size2) { size1=size2; }
buffer = new Ipp8u[size1];
sts = ippiFilterSobelNegVertBorder_8u16s_C1R (tempPtr, 1, dx, 2, imgSize, ippMskSize3x3, ippBorderRepl, 0, buffer); sts = ippiFilterSobelHorizBorder_8u16s_C1R(tempPtr, 1, dy, 2, imgSize, ippMskSize3x3, ippBorderRepl, 0, buffer); sts = ippiCanny_16s8u_C1R(dx, 2, dy, 2, ptr2, 1, imgSize, 10, 100, buffer); //ippsFree(buffer);
ofstream myfile; myfile.open("C://Users//Yuja//Documents//MATLAB//outputautoreg.raw", ios::out | ios::binary);
for(int i=0; i< 1024*1392; i++) { myfile.write((char*)&ptr2, sizeof(char)); }
return 0;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello androoy,
I guess, the problem is in the original image ptr and image show.
Do you have chance to show the imagein imgCache?
I upload one small sample (cpp code)to show the image, you may try it.
Regards,
Ying
//ippiCanny.cpp
#include
#include
#include
#include "ipp.h"
extern void* ipView_8u_C1R(const Ipp8u* pData, int step, IppiSize roi,
const char* caption, int isModalView); //from ippview.cpp
int main()
{
int width=1024;
int height=1392;
IppiSize roi = {1024, 1392};
int size, size1;
int imgStep16, imgStep8;
Ipp16s *dx = ippiMalloc_16s_C1(1024, 1392, &imgStep16);
Ipp16s *dy = ippiMalloc_16s_C1(1024, 1392, &imgStep16);
Ipp8u *imgCache = ippiMalloc_8u_C1(1024, 1392,&imgStep8);
Ipp8u *edges = ippiMalloc_8u_C1(1024, 1392, &imgStep8);
//ippiImageJaehne_8u_C1R(imgCache, imgStep8, roi);
IppiSize sqrSize={400, 400};
ippiSet_8u_C1R(255, imgCache+800*imgStep8+200, imgStep8, sqrSize);
/*for(int i=0; i < (width*height); i++) {
imgCache = (i/16);
}*/
ipView_8u_C1R( imgCache, imgStep8, roi, "imgCache", 0 );
ippiFilterSobelVertGetBufferSize_8u16s_C1R(roi, ippMskSize3x3, &size);
ippiFilterSobelHorizGetBufferSize_8u16s_C1R(roi, ippMskSize3x3, &size1);
if(size
if(size
ippiFilterSobelVertBorder_8u16s_C1R(imgCache, 1024*sizeof(Ipp8u), dx, 1024*sizeof(Ipp16s), roi, ippMskSize3x3, ippBorderRepl, 0, buffer);
ippiFilterSobelHorizBorder_8u16s_C1R(imgCache, 1024*sizeof(Ipp8u), dy, 1024*sizeof(Ipp16s), roi, ippMskSize3x3, ippBorderRepl, 0, buffer);
ippiCanny_16s8u_C1R(dx, 1024*sizeof(Ipp16s), dy, 1024*sizeof(Ipp16s), edges, 1024*sizeof(Ipp8u), roi, 100, 1000, buffer);
ipView_8u_C1R( edges, imgStep8, roi, "edges", 1 );
return 0;
}
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The problem looks be the parameter: widthSteps.
widthStep: Stride or step in bytes through theimage.it isthe width ofimagerow, but in bytes.
So you may change all of 1 or 2 inabove code to imgSize.width*sizeof(Ipp8u) or dy.width*sizeof(Ipp16s).
or other strides,depends on your array memory layout and datatype.
Best Wishes,
Ying H.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Ipp8u * doCanny(Ipp16u* ptr) {int width=1024;int height=1392;IppiSize roi = {1024, 1392};int size, size1;Ipp16s *dx = ippiMalloc_16s_C1(1024, 1392, &imgStep16);Ipp16s *dy = ippiMalloc_16s_C1(1024, 1392, &imgStep16);Ipp8u *imgCache = ippiMalloc_8u_C1(1024, 1392,&imgStep8);Ipp8u *edges = ippiMalloc_8u_C1(1024, 1392, &imgStep8);for(int i=0; i < (width*height); i++) {imgCache = (ptr/16);}ippiFilterSobelVertGetBufferSize_8u16s_C1R(roi, ippMskSize3x3, &size);ippiFilterSobelHorizGetBufferSize_8u16s_C1R(roi, ippMskSize3x3, &size1);if(size ippiCannyGetSize(roi, &size1);if(size Ipp8u * buffer = ippsMalloc_8u(size);ippiFilterSobelVertBorder_8u16s_C1R(imgCache, 1024*sizeof(Ipp8u), dx, 1024*sizeof(Ipp16s), roi, ippMskSize3x3, ippBorderRepl, 0, buffer);ippiFilterSobelHorizBorder_8u16s_C1R(imgCache, 1024*sizeof(Ipp8u), dy, 1024*sizeof(Ipp16s), roi, ippMskSize3x3, ippBorderRepl, 0, buffer);ippiCanny_16s8u_C1R(dx, 1024*sizeof(Ipp16s), dy, 1024*sizeof(Ipp16s), edges, 1024*sizeof(Ipp8u), roi, 100, 1000, buffer);return edges;}Ipp8u * doCanny(Ipp16u* ptr) {
int width=1024; int height=1392; IppiSize roi = {1024, 1392};
int size, size1; Ipp16s *dx = ippiMalloc_16s_C1(1024, 1392, &imgStep16); Ipp16s *dy = ippiMalloc_16s_C1(1024, 1392, &imgStep16);
Ipp8u *imgCache = ippiMalloc_8u_C1(1024, 1392,&imgStep8); Ipp8u *edges = ippiMalloc_8u_C1(1024, 1392, &imgStep8);
for(int i=0; i < (width*height); i++) { imgCache = (ptr/16); }
ippiFilterSobelVertGetBufferSize_8u16s_C1R(roi, ippMskSize3x3, &size); ippiFilterSobelHorizGetBufferSize_8u16s_C1R(roi, ippMskSize3x3, &size1);
if(sizeIpp8u * buffer = ippsMalloc_8u(size);
ippiFilterSobelVertBorder_8u16s_C1R(imgCache, 1024*sizeof(Ipp8u), dx, 1024*sizeof(Ipp16s), roi, ippMskSize3x3, ippBorderRepl, 0, buffer);ippiFilterSobelHorizBorder_8u16s_C1R(imgCache, 1024*sizeof(Ipp8u), dy, 1024*sizeof(Ipp16s), roi, ippMskSize3x3, ippBorderRepl, 0, buffer);
ippiCanny_16s8u_C1R(dx, 1024*sizeof(Ipp16s), dy, 1024*sizeof(Ipp16s), edges, 1024*sizeof(Ipp8u), roi, 100, 1000, buffer);
return edges;}Source image (just a square):edges image:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The code looks no problem. but from the result image,it looksstill some errors in data access.
1)For example, if your prc imageis aRGB 3 channal image with 8u data type, thenthe assignmentmay not correct.
2)The edge image is 8u 1 channale image with width=1024, hight=1392, but the shown edges image have about width 500, is there any problem in showing the image?
Additionally,it is recommended to use imgStep8, imgStep16 other thanthe width*sizeof(Ipp8u) as widthStep. Luckily, you have 1024 as width, they are same.If other value like 1000, then imgStep8!=1000*sizeof(Ipp8u).
Best Regards,
Ying
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Ipp16u * ptr;ptr = ippiMalloc_16u_C1(imgSize.width, imgSize.height, &imgStep16);FILE * fp=fopen("C://Users//Yuja//Documents//MATLAB//test.raw", "rb");fread(ptr, sizeof(short), 1024*1392, fp);

Ipp8u *edges1;//Ipp8u *edges2;edges1 = ippiMalloc_8u_C1(imgSize.width, imgSize.height, &imgStep8);edges2 = ippiMalloc_8u_C1(imgSize.width, imgSize.height, &imgStep8);edges1 = doCanny(ptr);//edges2 = doCanny(ptr2);ofstream myfile;myfile.open("C://Users//Yuja//Documents//MATLAB//edge1.raw", ios::out | ios::binary);for(int i=0; i< 1024*1392; i++) {myfile.write((char*)&edges1, sizeof(char));}myfile.close();
int size, size1;Ipp16s *dx = ippiMalloc_16s_C1(1024, 1392, &imgStep16);Ipp16s *dy = ippiMalloc_16s_C1(1024, 1392, &imgStep16);Ipp8u *imgCache = ippiMalloc_8u_C1(1024, 1392,&imgStep8);Ipp8u *edges = ippiMalloc_8u_C1(1024, 1392, &imgStep8);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello androoy,
I guess, the problem is in the original image ptr and image show.
Do you have chance to show the imagein imgCache?
I upload one small sample (cpp code)to show the image, you may try it.
Regards,
Ying
//ippiCanny.cpp
#include
#include
#include
#include "ipp.h"
extern void* ipView_8u_C1R(const Ipp8u* pData, int step, IppiSize roi,
const char* caption, int isModalView); //from ippview.cpp
int main()
{
int width=1024;
int height=1392;
IppiSize roi = {1024, 1392};
int size, size1;
int imgStep16, imgStep8;
Ipp16s *dx = ippiMalloc_16s_C1(1024, 1392, &imgStep16);
Ipp16s *dy = ippiMalloc_16s_C1(1024, 1392, &imgStep16);
Ipp8u *imgCache = ippiMalloc_8u_C1(1024, 1392,&imgStep8);
Ipp8u *edges = ippiMalloc_8u_C1(1024, 1392, &imgStep8);
//ippiImageJaehne_8u_C1R(imgCache, imgStep8, roi);
IppiSize sqrSize={400, 400};
ippiSet_8u_C1R(255, imgCache+800*imgStep8+200, imgStep8, sqrSize);
/*for(int i=0; i < (width*height); i++) {
imgCache = (i/16);
}*/
ipView_8u_C1R( imgCache, imgStep8, roi, "imgCache", 0 );
ippiFilterSobelVertGetBufferSize_8u16s_C1R(roi, ippMskSize3x3, &size);
ippiFilterSobelHorizGetBufferSize_8u16s_C1R(roi, ippMskSize3x3, &size1);
if(size
if(size
ippiFilterSobelVertBorder_8u16s_C1R(imgCache, 1024*sizeof(Ipp8u), dx, 1024*sizeof(Ipp16s), roi, ippMskSize3x3, ippBorderRepl, 0, buffer);
ippiFilterSobelHorizBorder_8u16s_C1R(imgCache, 1024*sizeof(Ipp8u), dy, 1024*sizeof(Ipp16s), roi, ippMskSize3x3, ippBorderRepl, 0, buffer);
ippiCanny_16s8u_C1R(dx, 1024*sizeof(Ipp16s), dy, 1024*sizeof(Ipp16s), edges, 1024*sizeof(Ipp8u), roi, 100, 1000, buffer);
ipView_8u_C1R( edges, imgStep8, roi, "edges", 1 );
return 0;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page