Вы находитесь на странице: 1из 2

Argc 0 and its argv is .

/test
Argc 1 and its argv is a
Argc 2 and its argv is 123
Argc 3 and its argv is b
Argc 4 and its argv is 456
From observing the result, I conclude some strategy for getting the command line
arguments and determining when to call appropriate function. In this particular program,
for loops is the best way to check the value of each element. This might starts from 1 to
the final value of argc. For the purpose of the program, the 0 argc is ignored because it
contains only the name of the executable program. One thing I noticed is that
globe.ppm was not included in argc. Therefore, argv[] will not has the pointer for this
string. In general, we can assume that arguments come after < and > will not perform by
the command line.
There are two modifications in the command line, add and mean filter. Because the
operations are entered by a single character, we can simply compare the argv inside the
condition of if statement. If the character matches, the corresponding function will be
called. The program also needs to take multiple operations in any order. Since we use
loop to scan the argument, the task is done automatically without any additional code.
From the last lab, we knew that the mean function was defined to calculate the average of
a block of pixel. Its mechanism is different from add function. In addf() function, each
color value in the original image is being overwrite with a new value. This allows the
program to modify the image multiple times without outputting the result into a different
array. In contrast, the meanf() function need to output the new filtered image into a
different array. If mean function try to modify and update the new value to the original
one, the image might look distort. Because of this behavior, I have to create a copy
function, which will be used to copy the averaged image back to the original image array.
Z pozorovn vsledek, jsem dospla k zvru njakou strategii pro zskn argumenty
pkazovho dku, a stanovit, kdy volat odpovdajc funkce. V tomto konkrtnm
programu, pro smyky je nejlep zpsob, jak kontrolovat hodnotu kadho prvku. Toto
by mohlo zan od 1 do konen hodnot argc. Pro ely tohoto programu, 0 argc je
ignorovn, protoe obsahuje pouze nzev spustiteln program. Jedna vc, kterou jsem si
viml, je, e "globe.ppm" nebyla zahrnuta do argc. Proto, argv [] nebude m ukazatel na
tento etzec. Obecn plat, e meme pedpokldat, e argumenty pijdou po <a>
nebude provdt pomoc pkazovho dku.
Tam jsou dv zmny v pkazovm dku, pidvat a znamenaj filtr. Vzhledem k tomu,
e operace se zadv jedin znak, meme jednodue porovnvat argv uvnit stavu if. V
ppad, e charakter odpovd, bude odpovdajc funkce se nazv.Program tak mus
brt vce operac v libovolnm poad. Vzhledem k tomu, pouvme smyky skenovn
argument, loha se provede automaticky bez dalho kdu.
Z poslednho laboratoi, vdli jsme, e prmrn funkce byla definovna vypotat
prmr bloku pixelu. Jeho mechanismus se li od funkce doplku. V addf () funkce,

kad hodnota barva z pvodnho obrazu je pepsat novou hodnotu. To umouje


program Chcete-li upravit nkolikrt, ani by vstup vsledek do jinho pole. Na rozdl
od funkce meanf () je teba, aby vstup nov filtrovan obraz do jinho pole. Je-li
prmrn funkce se sna zmnit a aktualizovat novou hodnotu pvodn, me obraz
vypadat naruit. Z dvodu tohoto chovn, musm vytvoit funkci koprovn, kter bude
pouita zkoprovat

Вам также может понравиться