Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8496571
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T23:53:28+00:00 2026-06-10T23:53:28+00:00

I’m getting crazy with this problem in OpenCv. I have to read a raw

  • 0

I’m getting crazy with this problem in OpenCv. I have to read a raw image, saved as an array in a binary file, and save it in the cvMat structure prepared in opencv. I did, and seems it works, I can access to the data. But I can’t plot it. It appears as a lot of diagonal lines. I have printed the numbers in the data matrix, and seems to be correct, except that some 0’s appear sometimes. This tell me that something with the ‘step’ field is running but I have no idea.

I write here the code I have, I hope some of you understand what is happening. Thanks a lot in advance! Omg.

#include <stdio.h>//printf;fread...
#include <stdlib.h>//malloc,calloc ...
#include <cv.h>
#include <highgui.h>
// READING IMAGES
int read_raw_image(FILE* filehandler,float*** datamatrix,int* height,int* width);
//THIS READ THE RAW FILE SAVING THE DATA IN A MATRIX [HEIGHT][WIDTH]
char image_file[]="IR.raw";
CvMat image;

//RUBBISH FOR READ THE IMAGE
FILE *Fimage;
int height,width;
float **pimage=(float**)malloc(sizeof(float**));
if((Fimage=fopen(image_file,"rb"))!= NULL)
{
    printf("\n\tFile: %s was opened correctly\n",image_file);
    read_raw_image(Fimage,&pimage,&height,&width);
    fclose(Fimage);
}
else {printf("\n\tFile: %s wasn't opened correctly\n",image_file);return 0;}

//NOW THE PROBLEM
image=cvMat(height,width,CV_32FC1,*pimage);//HEIGHT=640; WIDTH=480; THE NUMBERS ARE FLOATS
printf("%i",image.step);//THE NUMBER GIVEN IS 1920 (480*4)
int i,j;
for(j = 0;j<2;j++)//print just two rows
{
    for(i = 0;i<480;i++)
{
    printf("%f\n",cvmGet(image,j,i));/The numbers showed are well, except some 0's in the middle
        if(*(Aux->data.fl+(j*640)+i)<10)
    {
      printf("piiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii\n");//MAKE EASY TO SEE THE 0'S
    }
}
     printf("fila:%i\n",j);//Print the number of row at the end
}
 //AND NOW PLOT IT!
cvNamedWindow("win1",CV_WINDOW_AUTOSIZE);
cvShowImage("win1",&image);
cvWaitKey(0);
return 0;

I have no idea what can be the problem with the image.step values. I test to changed it. When I add more, some 0’s dissapear, but the image is no printed also.

Thanks for your help. Omg

P.D: The plot… I can’t post images!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T23:53:30+00:00Added an answer on June 10, 2026 at 11:53 pm

    Finally I achieve the solutions thanks to Dimitar. By some reason,each row finished with a float 0’s, this made an offset in each line, represented in the plot as four black dots. Since each line is now displaced, the result was a displaced 4 black dots, that seemed a diagonal line. The explanation for this 0’s at the end should be the way I saved the array (It doesn’t appear in the code) as a 2D dinamically allocated array, where first I allocated the number of rows, and later each row separatedly. However, the best way to save the images is in a 1D array, allocated just once. When you put it into the cvMat or IplImage, the code runs by rows and columns only with the knowledge of number of rows, number of cols and step (the length in bytes of each row). Also, if I changed the step in the original problem, by 16bytes, I obtain the 0’s were not displaces, and stand as a black column in to the right.
    Also it’s important to take care that raw files, and in the case of IR cameras, the numbers into the array have to be scaled to a 0-to-1 scale in order to be represented as grayscale plot.
    Thanks for your help all.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a reasonable size flat file database of text documents mostly saved in
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
This could be a duplicate question, but I have no idea what search terms
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
link Im having trouble converting the html entites into html characters, (&# 8217;) i

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.