473,387 Members | 1,548 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Is this the correct way to assign array value?

unsigned char *m_pVolumeData;
m_pVolumeData = new unsigned char[m_nSizeX * m_nSizeY * m_nSizeZ];

FILE *fp = fopen(filename, "rb");
if(fp) {
fread(m_pVolumeData, 1, m_nSizeX * m_nSizeY * m_nSizeZ, fp);
fclose(fp);
}

unsigned char *pSrcPixels = new unsigned char[m_nSizeX * m_nSizeY];
for(int m=0; m<m_nSizeX * m_nSizeY; m++) { //copy the value to
psrcpixels
//is this the correct way to assign the value to another array??
pSrcPixels[m] = m_pVolumeData[sliceNo * (m_nSizeX * m_nSizeY)+m];
}

Hi, like to check with you all.
Whether within the for loop, assigning the values are correct? I was to
assign the value of m_pVolume to pSrcPixels but it doesnt seem to
assign it correct. Pls help.

Sep 1 '06 #1
2 2152
radishcarrot wrote:
unsigned char *m_pVolumeData;
m_pVolumeData = new unsigned char[m_nSizeX * m_nSizeY * m_nSizeZ];

FILE *fp = fopen(filename, "rb");
if(fp) {
fread(m_pVolumeData, 1, m_nSizeX * m_nSizeY * m_nSizeZ, fp);
fclose(fp);
}

unsigned char *pSrcPixels = new unsigned char[m_nSizeX * m_nSizeY];
for(int m=0; m<m_nSizeX * m_nSizeY; m++) { //copy the value to
psrcpixels
//is this the correct way to assign the value to another array??
pSrcPixels[m] = m_pVolumeData[sliceNo * (m_nSizeX * m_nSizeY)+m];
Shouldn't this be:

pSrcPixels[m] = m_pVolumeData[sliceNo * m_nSizeZ + m];
}

Hi, like to check with you all.
Whether within the for loop, assigning the values are correct? I was to
assign the value of m_pVolume to pSrcPixels but it doesnt seem to
assign it correct. Pls help.

Best

Kai-Uwe Bux
Sep 1 '06 #2

Kai-Uwe Bux wrote:
radishcarrot wrote:
unsigned char *m_pVolumeData;
m_pVolumeData = new unsigned char[m_nSizeX * m_nSizeY * m_nSizeZ];

FILE *fp = fopen(filename, "rb");
if(fp) {
fread(m_pVolumeData, 1, m_nSizeX * m_nSizeY * m_nSizeZ, fp);
fclose(fp);
}

unsigned char *pSrcPixels = new unsigned char[m_nSizeX * m_nSizeY];
for(int m=0; m<m_nSizeX * m_nSizeY; m++) { //copy the value to
psrcpixels
//is this the correct way to assign the value to another array??
pSrcPixels[m] = m_pVolumeData[sliceNo * (m_nSizeX * m_nSizeY)+m];

Shouldn't this be:

pSrcPixels[m] = m_pVolumeData[sliceNo * m_nSizeZ + m];
This is incorrect, assuming the data is sequence of frames size
m_nSizeX x m_nSizeY the original poster was correct. It may be that
your assumption about file format is wrong. Look what you see as an
image and it may give you some clues. In particular check if image is
simply distorted or it has no sense at all.

Regards,

George Privalov
>
}

Hi, like to check with you all.
Whether within the for loop, assigning the values are correct? I was to
assign the value of m_pVolume to pSrcPixels but it doesnt seem to
assign it correct. Pls help.


Best

Kai-Uwe Bux
Sep 1 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: ckerns | last post by:
I want to loop thru an array of controls,(39 of them...defaults = 0). If value is null or non-numeric I want to assign the value of "0". rowString = "L411" //conrol name if (isNaN(eval...
16
by: sneill | last post by:
How is it possible to take the value of a variable (in this case, MODE_CREATE, MODE_UPDATE, etc) and use that as an object property name? In the following example I want 'oIcon' object to have...
26
by: Brett | last post by:
I have created a structure with five fields. I then create an array of this type of structure and place the structure into an array element. Say index one. I want to assign a value to field3 of...
7
by: Chris Wertman | last post by:
I am so lost on this one. Dim Ary as Integer = New Integer(4) {0,1,2,3} FAILS with the error: Array initializer has 1 too few elements. So I try Dim Ary as Integer = New Integer(3)...
9
by: sumit1680 | last post by:
Hi all, recently i tried the following peice of code in gcc int main () { char *ptr = "possible"; printf("%s",ptr); return (0); }
11
by: skumar434 | last post by:
Hi everybody, I am faceing problem while assigning the memory dynamically to a array of structures . Suppose I have a structure typedef struct hom_id{ int32_t nod_de; int32_t hom_id;
3
by: roopa.v1 | last post by:
Hi, How to assign long to character array and later extract it
11
by: jyck91 | last post by:
// Base Conversion // Aim: This program is to convert an inputted number // from base M into base N. Display the converted // number in base N. #include <stdio.h> #include <stdlib.h>...
2
by: Akino877 | last post by:
Hello, I am new to HTML and PHP. And I am trying to assign an array of values to the <option value=...> of a combo list. But what I am trying to do is not working. I can sucessfully get it to...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.